Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user = 'MyDomainusername'
- $password = ConvertTo-SecureString 'mypassword' -asplaintext -force
- $credential = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $user, $password
- try {
- $s = New-PSSession -ComputerName MyRemoteComputer -Credential $credential
- $remoteCommand = @"
- New-PSDrive -Name 'P' -PSProvider 'FileSystem' -Root '\main-serverFoldersDevOpsProjetcsJuniper'
- Get-Item -Path P:V1.6InstallFilesInstall.bat
- "@
- $scriptBlock = [Scriptblock]::Create($remoteCommand)
- $status = Invoke-Command -Session $s -ScriptBlock $scriptBlock
- Write-Host $status
- Exit-PSSession -Session $s
- }
- catch {
- #TODO Add exception handling
- }
Add Comment
Please, Sign In to add comment