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?

已提問 2 年前檢視次數 117 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南