Tuesday, June 20, 2017

Powershell script to perform action on remote computer

Powershell script to stop-website on a remote computer


$securepassword=Convertto-SecureString –String $(adminpassword) –AsPlainText –force
$mycredentials=New-object System.Management.Automation.PSCredential $(adminuser),$securepassword
Invoke-Command -ComputerName "computername" -ScriptBlock {
            Import-module WebAdministration;
            Stop-Website "TestCD"
} -Credential $mycredentials

No comments:

Post a Comment