Guest User

Untitled

a guest
Aug 15th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $user = 'MyDomainusername'
  2. $password = ConvertTo-SecureString 'mypassword' -asplaintext -force
  3. $credential = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $user, $password
  4.  
  5. try {
  6. $s = New-PSSession -ComputerName MyRemoteComputer -Credential $credential
  7.  
  8. $remoteCommand = @"
  9. New-PSDrive -Name 'P' -PSProvider 'FileSystem' -Root '\main-serverFoldersDevOpsProjetcsJuniper'
  10. Get-Item -Path P:V1.6InstallFilesInstall.bat
  11. "@
  12. $scriptBlock = [Scriptblock]::Create($remoteCommand)
  13. $status = Invoke-Command -Session $s -ScriptBlock $scriptBlock
  14.  
  15. Write-Host $status
  16. Exit-PSSession -Session $s
  17. }
  18. catch {
  19.  
  20. #TODO Add exception handling
  21. }
Add Comment
Please, Sign In to add comment