Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. $strScriptUser = "FULL-RIGHTS ADMIN ACCOUNT"
  2. $strPass = "PROBABLY PASSWORD123"
  3. $PSS = ConvertTo-SecureString $strPass -AsPlainText -Force
  4. $cred = new-object system.management.automation.PSCredential $strScriptUser,$PSS
  5. $Now = Get-Date -Format g
  6. $title = 'Restarting T1 Service'
  7. $msg = 'Please enter reason for restarting T1'
  8. $text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
  9. $Log = $env:username + ", " + $env:computername + ", " + $Now + ", " + $text
  10.  
  11. Invoke-Command -ComputerName "SYDSRV02" -scriptblock {
  12. Stop-Service -name "Test Service"
  13. Start-Sleep -s 25
  14. Start-Service -name "Test Service"
  15. } -Credential $cred
  16. Add-Content -Path \\Server\Path\Report.txt $Log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement