how to use secured credentials

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
 

I think you want invoke-command.

facepalm!

I’ll give it a try!

i now have this error

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

Try like this…

[pre]Invoke-Command -ScriptBlock {Get-ChildItem -Path C:} -ComputerName $computer -Credential $credObject[/pre]

yes Kiran that worked.

thanks!