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