diff --git a/scripts/Install-Prerequisites.ps1 b/scripts/Install-Prerequisites.ps1 new file mode 100644 index 0000000..9d16b90 --- /dev/null +++ b/scripts/Install-Prerequisites.ps1 @@ -0,0 +1,40 @@ +[CmdletBinding()] +Param( + # No parameters +) + +$RequiredPSModules = @( + 'ntobjectmanager' # Provides cmdlet 'Set-ExecutionAlias' +) + +$InstallPackageProviderSplat = @{ + Name = 'NuGet' + MinimumVersion = '2.8.5.201' + Force = $True + Confirm = $False +} +Install-PackageProvider @InstallPackageProviderSplat +$SetPSRepositorySplat = @{ + Name = 'PSGallery' + InstallationPolicy = 'Trusted' +} +Set-PSRepository @SetPSRepositorySplat +$InstallModuleSplat = @{ + Name = $RequiredPSModules + Force = $True + Confirm = $False +} +Install-Module @InstallModuleSplat +$SetPSRepositorySplat = @{ + Name = 'PSGallery' + InstallationPolicy = 'Untrusted' +} +Set-PSRepository @SetPSRepositorySplat + +# Double check whether the required PowerShell modules are available +ForEach ($Module in $RequiredPSModules) { + If ([boolean](Get-Module -Name $Module -ListAvailable) -ne $True) { + Write-Error -Message "Missing PowerShell module '$($Module)'" + Exit 1 + } +} \ No newline at end of file diff --git a/scripts/Install-WinGet.ps1 b/scripts/Install-WinGet.ps1 index 8db7589..5f9b05a 100644 --- a/scripts/Install-WinGet.ps1 +++ b/scripts/Install-WinGet.ps1 @@ -1,3 +1,4 @@ +#Requires -Modules 'NtObjectManager' [CmdletBinding()] Param( # None diff --git a/scripts/Server2019/Register-ScheduledTask.ps1 b/scripts/Register-ScheduledTask.ps1 similarity index 100% rename from scripts/Server2019/Register-ScheduledTask.ps1 rename to scripts/Register-ScheduledTask.ps1 diff --git a/scripts/Server2019/payload/Apply-FirstBootConfig.ps1 b/scripts/payload/Apply-FirstBootConfig.ps1 similarity index 100% rename from scripts/Server2019/payload/Apply-FirstBootConfig.ps1 rename to scripts/payload/Apply-FirstBootConfig.ps1