Skip to content

Latest commit

 

History

History
118 lines (76 loc) · 3.9 KB

initial-config.md

File metadata and controls

118 lines (76 loc) · 3.9 KB

Initial Config

Run PowerShell as admin.

It is best to do this with Windows PowerShell. Trying to do this with PowerShell Core can cause issues with conflicting PackageManagement versions.

 Windows PowerShell ctrl+shift+enter

Set Script Execution Policy

This has to be scoped to the local machine for PowerShell DSC to work.

Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force

Enable PSRemoting

Aside from having this enabled being handy, this must be enabled for DSC to work.

This cannot be done by default on a public network. When setting up a machine for the first time, Windows defaults new network connections to public. It must be remembered to set the network to private after the initial connection.

The SkipNetworkProfileCheck switch can be used to skip network profile check. This can be useful when I am using a VM with a network profile that is not connected to the network.

Enable-PSRemoting -Force

Install Chocolatey

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')

Update PowerShell Help

Not strictly necessary but nice to have. Several modules fail to update their help. Maybe I will look into it later.

Update-Help

Update PackageManagement Module

Out of the box PowerShell comes with PackageManagement version 1.0.0.1. I want to install the latest (1.4.7 as of now). Once the latest version is installed, the old version can be removed. In fact, I think it has to be removed to avoid issues with DSC later on. However, the default installed version does not show up in Get-InstalledModule. So it cannot be removed using Uninstall-Module. Instead, I just delete the folder.

Install-Module PackageManagement -Force

# I believe this will remove the package from memory allowing the directory to be deleted.
Remove-Module PackageManagement

rmdir 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1' -Force -Recurse

Configure System Wide Settings With PowerShell DSC

Download the DSC configuration file from this repo.

Invoke-WebRequest https://raw.githubusercontent.com/jasonmcboyd/Environment/master/DSC/SystemConfiguration.ps1 -OutFile SystemConfiguration.ps1

Run the configuration. This will create a MOF file at ./System/localhost.mof.

./SystemConfiguration.ps1

Optional, test the DSC state.

Test-DscConfiguration ./System

Apply the configuration.

Start-DscConfiguration ./System -Wait

Configure User Settings With PowerShell DSC

Download the DSC configuration file from this repo.

Invoke-WebRequest https://raw.githubusercontent.com/jasonmcboyd/Environment/master/DSC/UserConfiguration.ps1 -OutFile UserConfiguration.ps1

Run the configuration. This will create a MOF file at ./User/localhost.mof. This will require an Azure DevOps PAT to access the Azure DevOps environment package feed. The PAT must have read permissions for the Packaging scope. Also, the DSC engine will be running as admin, but we need to target the user for the user config. Use the Credential parameter to run as the target user.

!!!!! WARNING !!!!!

The mof file will store the PAT and the credentials in plain text. This repo has gitignore configured so that Git will ignore mof files to prevent them from being checked in on accident, but care should still be taken to delete the mof file after the configuration is applied.

$creds = Get-Credential
$azurePat = Get-Credential
./UserConfiguration.ps1 -Credential $creds -AzureDevOpsPAT $azurePat

Optional, test the DSC state.

Test-DscConfiguration ./User

Apply the configuration.

Start-DscConfiguration ./User -Wait

Install Ubuntu For WSL 2

wsl --install --distribution Ubuntu