Why checking AppStream Home Folder's MountStatus returns no value when run as a start script?

0

I have a PowerShell script that checks the storage connector registry key to get the mount status at startup but it never returns any value and eventually exceeds the 60 seconds limit.

$regHive = "HKLM:\SOFTWARE\Amazon\AppStream\Storage\$Env:AppStream_UserName"
function Get-HomeFolderMountStatus {
  Get-ChildItem -Path $regHive `
  | Where-Object { $_.Name.EndsWith('HomeFolder') } `
  | Get-ItemPropertyValue -Name MountStatus
}

Write-Output "Mount status: $(Get-HomeFolderMountStatus)"

while ("$(Get-HomeFolderMountStatus)" -ne '2') {
  Start-Sleep -Seconds 3

  Write-Output "Mount status: $(Get-HomeFolderMountStatus)"
}
...

Upon checking the logs the value for MountStatus is null

Mount status: 
Mount status: 
...
The session script has not completed within the configured waiting time of 60000 ms. Logs will be truncated shortly after this point.

But if I test the script during the session it works and Mount Status is 2. powershell

So why doesn't the registry lookup return a value for MountStatus when run as a start script?

gefragt vor 2 Jahren103 Aufrufe
Keine Antworten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen