daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 25th, 2016 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Write-Log
  2. {
  3.     param([Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)][AllowEmptyString()][string]$Message)
  4.     Write-Verbose -Verbose ("[{0:s}] {1}`r`n" -f (get-date), $Message)
  5. }
  6.  
  7.  
  8. $destHost="10.9.13.21"
  9. $user = "administrator"
  10. $pass =  ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force
  11. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $pass
  12.  
  13.  
  14. #net start WinRM
  15.  
  16. if ((Get-Service -Name winrm).Status -ne "Running")
  17.     { winrm quickconfig }
  18.  
  19. $list = (get-item wsman:\localhost\Client\TrustedHosts).value
  20.  
  21. if (!($list.contains("$destHost")))
  22.     { write-log "Item not in trusted list"; Set-Item wsman:\localhost\Client\TrustedHosts $destHost -Concatenate -Force }
  23.  
  24. Enter-PSSession -ComputerName $destHost -credential $cred
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top