how to use secured credentials

Welcome Forums General PowerShell Q&A how to use secured credentials

Viewing 5 reply threads
  • Author
    Posts
    • #206226
      Participant
      Topics: 18
      Replies: 29
      Points: 279
      Rank: Contributor

      hi everyone,

      I’m building an application so that our Service Desk can connect to remote computers and browse the file system to get at logs.

      I tried to create a secured credential file but when I read that file and pass its arguments to invoke-item, it won’t work.

      Can someone tell me what I’m doing wrong?

      This is what I have so far:

      $computer = 'somename'
      $creds = Get-Credential
      $creds | Export-Clixml -Path "$env:USERPROFILE\AppData\Local\MyCompany\UserCreds.xml"
      $creds = Import-Clixml -Path "$env:USERPROFILE\AppData\Local\Mycompany\UserCreds.xml"
      $credObject = New-Object System.Management.Automation.PSCredential -ArgumentList $creds.username, $creds.password
      Invoke-Item "\\$computer\c$" -Credential $credObject

       

      • This topic was modified 3 months ago by Kiran. Reason: Code formating
      • This topic was modified 3 months ago by Kiran.
    • #206235
      js
      Participant
      Topics: 29
      Replies: 810
      Points: 2,432
      Helping Hand
      Rank: Community Hero

      I think you want invoke-command.

    • #206241
      Participant
      Topics: 18
      Replies: 29
      Points: 279
      Rank: Contributor

      facepalm!

      I’ll give it a try!

    • #206250
      Participant
      Topics: 18
      Replies: 29
      Points: 279
      Rank: Contributor

      i now have this error

      ERROR: Invoke-Command : Parameter set cannot be resolved using the specified named parameters.

    • #206253
      Moderator
      Topics: 3
      Replies: 216
      Points: 1,176
      Helping Hand
      Rank: Community Hero

      Try like this…

      Invoke-Command -ScriptBlock {Get-ChildItem -Path C:\} -ComputerName $computer -Credential $credObject
      • This reply was modified 3 months ago by Kiran.
    • #206265
      Participant
      Topics: 18
      Replies: 29
      Points: 279
      Rank: Contributor

      yes Kiran that worked.

      thanks!

Viewing 5 reply threads
  • You must be logged in to reply to this topic.