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년 전103회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠