2023-09-15 14:33:51 +00:00
|
|
|
# Function to configure the prefered scope option as Machine
|
|
|
|
function Add-ScopeMachine
|
|
|
|
{
|
|
|
|
[CmdletBinding()]
|
|
|
|
param
|
|
|
|
(
|
|
|
|
[string]$SettingsPath
|
|
|
|
)
|
|
|
|
|
|
|
|
if (Test-Path -Path $SettingsPath -ErrorAction SilentlyContinue)
|
|
|
|
{
|
|
|
|
$ConfigFile = (Get-Content -Path $SettingsPath -ErrorAction SilentlyContinue | Where-Object -FilterScript {
|
|
|
|
($_ -notmatch '//')
|
|
|
|
} | ConvertFrom-Json)
|
|
|
|
}
|
2022-05-08 12:19:41 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
if (!$ConfigFile)
|
|
|
|
{
|
|
|
|
$ConfigFile = @{}
|
|
|
|
}
|
2022-05-08 12:19:41 +00:00
|
|
|
|
2023-09-15 14:33:51 +00:00
|
|
|
if ($ConfigFile.installBehavior.preferences.scope)
|
|
|
|
{
|
|
|
|
$ConfigFile.installBehavior.preferences.scope = 'Machine'
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$Scope = (New-Object -TypeName PSObject -Property $(@{
|
|
|
|
scope = 'Machine'
|
|
|
|
}))
|
|
|
|
$Preference = (New-Object -TypeName PSObject -Property $(@{
|
|
|
|
preferences = $Scope
|
|
|
|
}))
|
|
|
|
$null = (Add-Member -InputObject $ConfigFile -MemberType NoteProperty -Name 'installBehavior' -Value $Preference -Force)
|
|
|
|
}
|
|
|
|
|
|
|
|
$null = ($ConfigFile | ConvertTo-Json | Out-File -FilePath $SettingsPath -Encoding utf8 -Force -Confirm:$false)
|
2022-10-26 22:49:10 +00:00
|
|
|
}
|