$server = “YOURSERVERNAME”
$password = “yourpassword”
$username = “yourusername”
Write-Host “Start reset”
$SecurePassword = $password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $SecurePassword
$Session = New-PSSession -ComputerName $server -Credential $cred
Invoke-Command -Session $Session -ScriptBlock {
Restart-WebAppPool YourAppPoolName
Write-EventLog -LogName Application -Source MyScript -EventId 3001 -Message “AppPool restart was called from remote”
}
Write-Host “Reset done”