How to test writing to a file share path using credential?
问题 I have an array of Credential objects and I would like to test that these credentials have permissions to write a file to a file share. I was going to do something like $myPath = "\\path\to\my\share\test.txt" foreach ($cred in $credentialList) { "Testing" | Out-File -FilePath $myPath -Credential $cred } but then I discovered that Out-File doesn't take Credential as a parameter. What's the best way to solve this? 回答1: You can use New-PSDrive: $myPath = "\\path\to\my\share" foreach ($cred in