YokoRUMsetPC.psm1
<#
.SYNOPSIS Make HWID CSV file .DESCRIPTION Gets HWID PC information and makes 'AutopilotHWID.csv' file into folder HWID at system root drive. .EXAMPLE PS C:\> Get-HWIDcsv .NOTES No additional info, this is for private use. #> function Get-HWIDcsv { [CmdletBinding()] param () $admin = [boolean]([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (!$admin) { return Write-Error -Message "Must run in Admin console." -Category AuthenticationError } Write-Output -InputObject "Generating hardware hash file." Install-Script -Name Get-WindowsAutoPilotInfo -Force $hashFolder = $env:SystemDrive + "\HWID" New-Item -Path $hashFolder -ItemType Directory -Force | Out-Null Set-Location -Path $hashFolder Get-WindowsAutopilotInfo.ps1 -OutputFile "AutopilotHWID.csv" Start-Process -FilePath explorer $hashFolder } <# .SYNOPSIS Install Serbian .DESCRIPTION Install Serbian language packs, cyrilic and latin. .EXAMPLE PS C:\> Install-SerbianLanguage .NOTES Additional information about the function. #> function Install-SerbianLanguage { [CmdletBinding(SupportsShouldProcess = $true)] param () $admin = [boolean]([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (!$admin) { return Write-Error -Message "Must run in Admin console." -Category AuthenticationError } if ($pscmdlet.ShouldProcess("Target", "Operation")) { Write-Output -InputObject "Intalling Serbian cyrilic language pack." Install-Language -Language "sr-Cyrl-RS" Write-Output -InputObject "Intalling Serbian latin language pack." Install-Language -Language "sr-Latn-RS" } } <# .SYNOPSIS Imstall M3 for user .DESCRIPTION A detailed description of the Install-M3 function. .PARAMETER web Install online. .EXAMPLE PS C:\> Install-M3 .NOTES Install M3 for user. #> function Install-M3 { [CmdletBinding(SupportsShouldProcess = $true)] param ( [switch]$web ) if ($pscmdlet.ShouldProcess("Target", "Operation")) { if ($web) { Start-Process -FilePath msedge -ArgumentList "https://Twsm3isoprd.yokohama-tws.com:20108/mango" } else { Start-Process -FilePath explorer -ArgumentList "P:\IT\Programi\M3" } } } <# .SYNOPSIS Set 2 factor authorisation .DESCRIPTION Set two factor authorisation to Microsoft authenticator. .EXAMPLE PS C:\> Set-TwoFactorAuthorisation .NOTES Additional information about the function. #> function Set-TwoFactorAuthorisation { [CmdletBinding(SupportsShouldProcess = $true)] param () if ($pscmdlet.ShouldProcess("Target", "Operation")) { Start-Process -FilePath "https://aka.ms/mfasetup" } } <# .SYNOPSIS Set user PC .DESCRIPTION Private cmdlet for setting Yokohama - Serbia - Ruma user PC. .PARAMETER SpecUser Specify user to apply settings. .PARAMETER SetAllUsers Apply setting to all users on PC. .EXAMPLE PS C:\> Set-YokoPC .NOTES Private cmdlet, no additional info. #> function Set-YokoPC { [CmdletBinding(SupportsShouldProcess = $true)] param ( [string]$SpecUser, [switch]$SetAllUsers ) $ProgressPreference = 'SilentlyContinue' [string]$line = "-----------------------------------------------------------------------------" $admin = [boolean]([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (!$admin) { return Write-Error -Message "Must run in Admin console." -Category AuthenticationError } # Parameters $winVer = (Get-ComputerInfo -Property OsName).OsName $culture = (Get-Culture).Name $status = New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS -ErrorAction SilentlyContinue if (!$status) { Write-Warning -Message "Cannot make registry value." } $userDetails = Get-CimInstance -Class win32_useraccount | Where-Object{ $_.status -eq 'ok' } #region Functions function Show-TrayIcon { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$sid ) $Key = "HKU:\${sid}\Control Panel\NotifyIconSettings" $Property = "IsPromoted" if (Test-Path -LiteralPath $Key -PathType 'Container' -ErrorAction SilentlyContinue) { Get-ChildItem -LiteralPath $Key | Where-Object { $_.GetValue($Property) -ne 1 } | ForEach-Object { Set-ItemProperty -LiteralPath ($_.PSPath) -Name $Property -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null } # Write-Output -InputObject "Set IsPromoted to 1 for $($_.PSPath)" } else { return Write-Warning -Message "Registry path '$Key' not found." } } function Enable-DeleteConfirmation { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$sid ) $RegCheck = Get-ItemProperty -Path "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -ErrorAction SilentlyContinue if (!$RegCheck) { New-Item -Path "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\" -Force | Out-Null } New-ItemProperty -Path "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\" -Name "ConfirmFileDelete" -Value 1 -Force -ErrorAction SilentlyContinue | Out-Null } function Move-TaskBarLeft { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$sid ) New-ItemProperty -Path "HKU:\${sid}\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value 0 -PropertyType DWORD -Force -ErrorAction SilentlyContinue | Out-Null } function Enable-DesktopIcon { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$sid ) $desktopIconSettingsPath = "HKU:\${sid}\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" $desktopSettings = "HKU:\${sid}\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\" $ThemesChange = "ThemeChangesDesktopIcons" $MyComputer = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" $UserFiles = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" $Network = "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" New-ItemProperty -Path $desktopIconSettingsPath -Name $MyComputer -Value 0 -Force | Out-Null New-ItemProperty -Path $desktopIconSettingsPath -Name $UserFiles -Value 0 -Force | Out-Null New-ItemProperty -Path $desktopIconSettingsPath -Name $Network -Value 0 -Force | Out-Null New-ItemProperty -Path $desktopSettings -Name $ThemesChange -Value 0 -Force | Out-Null } function Disable-TaskView { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [string]$sid ) New-ItemProperty -Path "HKU:\${sid}\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value 0 -Force | Out-Null } function Remove-Widget { [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true)] [string]$sid ) if ($pscmdlet.ShouldProcess("Target", "Operation")) { New-ItemProperty -Path "HKU:\${sid}\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value 0 -Force | Out-Null } } #endregion # Set culture to en-US Write-Output -InputObject $line if ($culture -ne "en-US") { Write-Output -InputObject "Setting region format to:`tEnglish (United States)" Set-Culture -CultureInfo en-US } else { Write-Output -InputObject "Region format already set to:`tEnglish (United States)" } # Set user(s) Write-Output -InputObject $line if ($SpecUser) { if (!($userDetails.Name -eq $SpecUser)) { return Write-Error -Message "$SpecUser does not exist." -Category InvalidData } Write-Output -InputObject "Applyibg settings to:`t$SpecUser" } elseif ($SetAllUsers) { $SpecUser = $null Write-Output -InputObject "Applyibg settings for:`t`tall users" } else { $CurrentUsername = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object -Property username $User = $CurrentUsername.username $User = $User.Split("\") $SpecUser = $User[1] Write-Output -InputObject "Current user set applying:`t$SpecUser" } # Set date, time, region format if ($SpecUser) { Format-DateTimeRegion -SpecUser $SpecUser -DateFormat dd.MM.yyyy } else { Format-DateTimeRegion -DateFormat dd.MM.yyyy } # Show all tray icons if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Showing tray icons for user:`t$SpecUser" Show-TrayIcon -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Showing tray icons for user:`t$UserName" $sid = $user.SID Show-TrayIcon -sid $sid $count = $count + 1 } } # Enable delete file confirmation Write-Output -InputObject $line if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Delete confirm enabled for:`t$SpecUser" Enable-DeleteConfirmation -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Delete confirm enabled for:`t$UserName" $sid = $user.SID Enable-DeleteConfirmation -sid $sid $count = $count + 1 } } # Move taskbar to left Write-Output -InputObject $line if ($WinVer -like "*11*") { if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Moving taskbar left for:`t$SpecUser" Move-TaskBarLeft -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Moving taskbar left for:`t$UserName" $sid = $user.SID Move-TaskBarLeft -sid $sid $count = $count + 1 } } } else { Write-Warning "Windows 11 not detected, not moving tasbar to the left side." } # Enable desktop icons Write-Output -InputObject $line if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Desktop icons enabled for:`t$SpecUser" Enable-DesktopIcon -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Desktop icons enabled for:`t$UserName" $sid = $user.SID Enable-DesktopIcon -sid $sid $count = $count + 1 } } # Disable TaskView Write-Output -InputObject $line if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Disabling task view for:`t$SpecUser" Disable-TaskView -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Disabling task view for:`t$UserName" $sid = $user.SID Disable-TaskView -sid $sid $count = $count + 1 } } # Remove-Widgets Write-Output -InputObject $line if ($SpecUser) { foreach ($user in $userDetails) { if ($user.Name -eq $SpecUser) { $sid = $user.SID Write-Output -InputObject "Removing widgets for user:`t$SpecUser" Remove-Widget -sid $sid # Write-Output -InputObject "User's $SpecUser SID:`t`t$sid" } } } else { [int]$count = 0 foreach ($user in $userDetails) { $UserName = $userDetails.Name[$count] Write-Output -InputObject "Removing widgets for user:`t$UserName" $sid = $user.SID Remove-Widget -sid $sid $count = $count + 1 } } # Set default apps Start-Process -PSPath ms-settings:defaultapps # Install .NET 3.5 package Write-Output -InputObject $line Install-dotNET3.5 Write-Output -InputObject "$line`n" Write-Warning -Message "Need to restart PC to changes take the effect." } |