Hello,
I am trying to use PowerCLI to check if a VM is connected to a share drive (let's call it the F: drive, with UNC \\10.0.0.1\drive\share for example). When I log into the VM, the share is connected, and I have full access to it. When I run the following it returns True in both cases, indicating the drive is connected as well:
- "Test-Path -Path F:\\"
- "Test-Path -Path \\10.0.01\drive\share"
Also, if i run the following it also displays the F: drive and says it is "Okay" (connected)
However, when I run the Test-Path commands via Invoke-VMScript, it returns False... When I run the net use command via Invoke-VMScript it returns:
Status Local Remote Network
-------------------------------------------------------------------------------
Unavailable F: \\10.0.0.1\drive\share Microsoft Windows Network
Is there some reason why Invoke-VMScript cannot see or access these shares? Here is a simple example of my powershell code:
$CheckDriveScript = @{
ScriptText = "Test-Path -Path F:\\"
#ScriptText = "Test-Path -Path \\10.0.0.1\drive\share"
#ScriptText = "net use"
VM = $vmo
GuestUser = "User"
GuestPassword = ConvertTo-SecureString "Password" -AsPlainText -Force
ScriptType = 'PowerShell'
}
$Result = Invoke-VMScript @CheckDriveScript
Write-Host "Results of Check Drive Script:"
Write-Host $Result.scriptoutput