I use this function to mount the drive
Function MountDrive() {
$name = "Functional_Storage"
$datastore = Get-Datastore $name
New-PSDrive -Location $datastore -Name fs -PSProvider VimDatastore -Root "\"
cd fs:
}
I now try to do a directory listing using a wildcard
PS fs:\> Get-ChildItem "Somthing*"
Get-ChildItem : Cannot find drive. A drive with the name 'fs' does not exist.
At line:1 char:14
+ Get-ChildItem <<<< "Somthing*"
+ CategoryInfo : ObjectNotFound: (fs:String) [Get-ChildItem], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
However, if I had just issued a Get-Childitem, no error occurs... how is it that fs becomes non-existent only if I use a wildcard?
I suspect that this might be a scope issue.
You set up the psdrive inside a function, but you seem to perform the Get-ChildItem outside the function.
I think the psdrive is only available inside the function.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I suspect that this might be a scope issue.
You set up the psdrive inside a function, but you seem to perform the Get-ChildItem outside the function.
I think the psdrive is only available inside the function.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
***UPDATE*** : Yep. You are right.
I think you're right. I have been having some trouble about scope and this happens when I am using the function with "interactive mode," thanks for clearing this up