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?

asked a year ago101 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions