Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. $username = "domainusername"
  2. $password = "Welcome1234$"
  3. $secstr = New-Object -TypeName System.Security.SecureString
  4. $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
  5. $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
  6. Invoke-Command -Credential $cred -Computer VM1{
  7. New-Item \VM2sapmntSIDSYSprofiletest.txt -ItemType file
  8. }
  9.  
  10. Access to the path '\vue2dvpahs5sapmntHS5SYSprofiletest.txt' is denied.
  11. + CategoryInfo : PermissionDenied: (\vue2dvpahs5s...rofiletest.txt:String) [New-Item], UnauthorizedAccessException
  12. + FullyQualifiedErrorId : NewItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement