@@ -81,37 +81,34 @@ function Get-WingetCmd {
8181
8282# Function to configure prefered scope option as Machine
8383function Add-ScopeMachine {
84- # Function to configure prefered scope option as Machine
85- function Add-ScopeMachine {
86- # Get Settings path for system or current user
87- if ([System.Security.Principal.WindowsIdentity ]::GetCurrent().IsSystem) {
88- $SettingsPath = " $Env: windir \System32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
89- }
90- else {
91- $SettingsPath = " $env: LOCALAPPDATA \Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
92- }
93-
94- $ConfigFile = @ {}
84+ # Get Settings path for system or current user
85+ if ([System.Security.Principal.WindowsIdentity ]::GetCurrent().IsSystem) {
86+ $SettingsPath = " $Env: windir \System32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
87+ }
88+ else {
89+ $SettingsPath = " $env: LOCALAPPDATA \Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json"
90+ }
9591
96- # Check if setting file exist, if not create it
97- if (Test-Path $SettingsPath ) {
98- $ConfigFile = Get-Content - Path $SettingsPath | Where-Object { $_ -notmatch ' //' } | ConvertFrom-Json
99- }
100- else {
101- New-Item - Path $SettingsPath
102- }
92+ $ConfigFile = @ {}
10393
104- if ($ConfigFile.installBehavior.preferences ) {
105- Add-Member - InputObject $ConfigFile.installBehavior.preferences - MemberType NoteProperty - Name ' scope' - Value ' Machine' - Force
106- }
107- else {
108- $Scope = New-Object PSObject - Property $ (@ {scope = ' Machine' })
109- $Preference = New-Object PSObject - Property $ (@ {preferences = $Scope })
110- Add-Member - InputObject $ConfigFile - MemberType NoteProperty - Name ' installBehavior' - Value $Preference - Force
111- }
94+ # Check if setting file exist, if not create it
95+ if (Test-Path $SettingsPath ) {
96+ $ConfigFile = Get-Content - Path $SettingsPath | Where-Object { $_ -notmatch ' //' } | ConvertFrom-Json
97+ }
98+ else {
99+ New-Item - Path $SettingsPath
100+ }
112101
113- $ConfigFile | ConvertTo-Json | Out-File $SettingsPath - Encoding utf8 - Force
102+ if ($ConfigFile.installBehavior.preferences ) {
103+ Add-Member - InputObject $ConfigFile.installBehavior.preferences - MemberType NoteProperty - Name ' scope' - Value ' Machine' - Force
104+ }
105+ else {
106+ $Scope = New-Object PSObject - Property $ (@ {scope = ' Machine' })
107+ $Preference = New-Object PSObject - Property $ (@ {preferences = $Scope })
108+ Add-Member - InputObject $ConfigFile - MemberType NoteProperty - Name ' installBehavior' - Value $Preference - Force
114109 }
110+
111+ $ConfigFile | ConvertTo-Json | Out-File $SettingsPath - Encoding utf8 - Force
115112}
116113
117114function Install-Prerequisites {
0 commit comments