From 40c0936ea87afe0a7ad42ea84583f4391af03c1e Mon Sep 17 00:00:00 2001 From: Zachary Gorman Date: Thu, 20 Jun 2024 08:57:22 -0700 Subject: [PATCH] Apps doesn't make a profile anymore --- Private/Apps.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Private/Apps.ps1 b/Private/Apps.ps1 index 2aa2509..a111b59 100644 --- a/Private/Apps.ps1 +++ b/Private/Apps.ps1 @@ -24,10 +24,13 @@ Select-Object @{N='DisplayName';E={$_.Name}} | Sort-Object -Property DisplayName } else { - $localapps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1) -ScriptBlock { - Get-Package -ProviderName Programs -IncludeWindowsInstaller | - Select-Object @{N='DisplayName';E={$_.Name}} | - Sort-Object -Property DisplayName + #Checks if pc is online so Invoke doesn't hang on offline pc + if (Test-Connection -ComputerName $comp -Count 1) { + $localapps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1 -NoMachineProfile) -ScriptBlock { + Get-Package -ProviderName Programs -IncludeWindowsInstaller | + Select-Object @{N='DisplayName';E={$_.Name}} | + Sort-Object -Property DisplayName + } } }