Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

PowerShell Test-Path Command

$
0
0

Hi,

I am having problems with Test-Path Cmdlet

I have created two variables Username and Password and then I am creating a PSCredential Object

$credentials = New-Object -typename System.Management.Automation.PSCredential -ArgumentList $username, $password

$FullRemotePath= "\\$Server\C:\Program Files\Redstor Online Backup Plus"

Then I am passing these arguments to Test-Path Cmdlet

Test-Path -path $FullRemotePath -Credential $credentials

I am getting the following Error:

Test-Path : Cannot retrieve the dynamic parameters for the cmdlet. The provider does not support the use of credential

s. Perform the operation again without specifying credentials.

At C:\Users\binyamin.k\Documents\Power_Shell_Programs\MyTest.ps1:35 char:10

+ Test-Path <<<<  -path $FullRemotePath -Credential $credentials

    + CategoryInfo          : InvalidArgument: (:) [Test-Path], ParameterBindingException

    + FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.Commands.TestPathCommand

CAN YOU PLEASE HELP ME ON THIS? I HAVE ALSO TRIED TO USE INVOKE-COMMAND BUT I GOT THE FOLLOWING ERROR

Connecting to remote server failed with the following error message : The WinRM client cannot process

the request. Default authentication may be used with an IP address under the following conditions: the transport is HT

TPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure

TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to

set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshoot

ing Help topic.

    + CategoryInfo          : OpenError: (:) [], PSRemotingTransportException

    + FullyQualifiedErrorId : PSSessionStateBroken

Regards


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>