krehberger
12/9/2017 - 11:28 AM

Setup a Powershell Environment

Setup a Powershell Environment

# requires full administrative permission
# start only manual in ISE Editor

# Execution Policy für Powershell Scripte setzen
Set-ExecutionPolicy -scope CurrentUser -ExecutionPolicy RemoteSigned -Force

# PowerShell Hilfe aktualisieren
update-help -Force
update-help -UICulture En-Us -Force

# Nach installation von git das Modul posh-git installieren
Update-Module PowerShellGet -Force
Install-Module -Name posh-git -Force
Get-Module -Name posh-git -ListAvailable

#WindowsPowerShell Verzeichnis und Default Profile anlegen
New-Item -Path (Split-Path -Parent -Path $profile) -ItemType Directory  
#New-Item -ItemType file $profile
Copy-Item -Path ("$env:USERPROFILE\OneDrive\Repository\Powershell\Profiles\" + (split-path -Path $profile -Leaf)) -Destination $profile

# Module installieren
New-Item -Path ((Split-Path -Parent -Path $profile) + '\Modules\PowershellISE') -ItemType Directory  
Copy-Item -Path ("$env:USERPROFILE\OneDrive\Repository\Powershell\Modules\PowershellISE\PowershellISE.psm1") -Destination "$home\Documents\WindowsPowerShell\Modules\PowershellISE\PowershellISE.psm1"

# ISESteriods installieren
install-module -Name isesteroids -Scope CurrentUser

# Download example profile for powershell git  (see http://mikefrobbins.com/2016/02/09/configuring-the-powershell-ise-for-use-with-git-and-github/)
$client = new-object System.Net.WebClient
$client.DownloadFile("https://raw.githubusercontent.com/mikefrobbins/PowerShell/dev/MrToolkit/profile.ps1",(split-path -path $profile -Parent) + '\Profile.Example_Posh-Git.ps1')

# Plaster installieren
Install-Module Plaster -Scope CurrentUser

# Azure Module
Install-Module AzureRM

# Pester installieren
$info = [Ordered]@{
    'Pester vorhanden' = (Get-Module -Name Pester -ListAvailable) -ne $null
    Version = (Get-Module -Name Pester -ListAvailable).Version
    'Aktuelle Version' = (Find-Module -Name Pester).Version
}

New-Object -TypeName PSObject -Property $info

# See Installation and Update of Pester at https://github.com/pester/Pester/wiki/Installation-and-Update
Install-Module -Name Pester -Force -SkipPublisherCheck