Jump to content

Help with Powersell Script


profyt7
 Share

Recommended Posts

Hey Guys,

I am almost there but feel I am missing something that is right in front of me and need another set of eyes.

 

I am trying to run the following powershell file with the following parameters. This works in powershell just fine.

Reset-LocalAdminPassword.ps1 -Password $secureString

 

I created an autoit script to do a few other things but from venturing in the forums I found some code and did the following:

;THIS COMMAND WILL RUN THE powershell script
$iDir = "C:\test\script\Reset-LocalAdminPassword.ps1"
Run('cmd /k C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File ' & '"' & $iDir & '-Password $secureString')
Sleep(15000)

 

The problem is that when it runs it gives me a message that C:\test\script\Reset-LocalAdminPassword.ps1-Password $secureString' is not a valid ps1 file.

I cannot seem to get it to run the ps1 file with the -Password $secureString' parameter. It keeps cobining the ps1 path and the parameters all as one.

I am sure this is something I am overlooking but I have been battling with this for a few hours now and just don't know what I am missing.

 

Link to comment
Share on other sites

Consider this snippet and the difference between the two message boxes:

$sString = "hi"
MsgBox(0, 0, 'The var is: $sString')
MsgBox(0, 0, 'The var is: ' & $sString)

Also take a look at using ShellExecute(Wait), it's more versatile than Run(Wait).

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...