I'm having trouble running a powershell script automatically. When every I call or Execute the script, I get a security prompt requesting I enter "R" to run. I have already set the execution policy to 'unrestricted' and have verified its set. Does anyone have any suggestions?
Security Warning: Run only scripts that you trust. while scripts from the Internet can be useful, the script can potentially harm your computer. Do you want to run C:\test\win7.ps1?
I am currently running the powershell script via powershell.exe call in cmd. I have also tried to run this directly from powershell and get the same error message.
powershell -command C:\nst\win7.ps1 "var1" "var2" "var3"
I have also tried running the following command via cmd:
powershell -executionpolicy unrestricted -command C:\nst\win7.ps1 "var1" "var2" "var3"
Win7 Script:
$domain = $args[0]
$pwd = $args[2]
$usr = $args[1]
$password = ConvertTo-SecureString $pwd -AsPlainText -Force
$username = "$domain\$usr"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -Credential $credential
Any and all help would be greatly appreciated