Advertisement
Guest User

Untitled

a guest
Apr 4th, 2017
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. $Username = Read-Host "Please enter Username"
  2. $Password = read-host "please enter Password"
  3. $pass = ConvertTo-SecureString -AsPlainText $Password -Force
  4. $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
  5. $computers = gc c:testfile.txt
  6. foreach ($Computer in $computers)
  7. {
  8. Invoke-command -ComputerName $computers -credential $cred -ErrorAction Stop -ScriptBlock {Invoke-Expression -Command:"cmd.exe /c 'ipconfig'" | out-file c:testoutput.txt -append}
  9. }
  10. cls
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement