Last active
August 23, 2016 02:17
-
-
Save mattmcnabb/57aff66df11c7e97c3fb10db552d3730 to your computer and use it in GitHub Desktop.
Blog_What's-in-your-profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Import Credentials | |
$SAMMattAdmin = (Import-Clixml "$DirScripts\Creds\cred_SAM_mattadmin_$Env:ComputerName.xml") | |
$UPNattAdmin = (Import-Clixml "$DirScripts\Creds\cred_UPN_mattadmin_$Env:ComputerName.xml") | |
### Extend the module path to include Onedrive folder | |
$Env:PSModulePath = $Env:PSModulePath -replace 'c:\\Users\\matt\\My Documents\\WindowsPowerShell\\Modules','' | |
$Env:PSModulePath += ";$DirScripts\Modules" | |
### Custom prompt | |
. "$PSScriptRoot\prompt.ps1" | |
### Import commonly used modules | |
Import-Module ActiveDirectory | |
Import-Module ADLibrary | |
Import-Module MSOLLibrary | |
Import-Module ServerAdminLibrary | |
Import-Module GeneralLibrary | |
switch ($Env:PROCESSOR_ARCHITECTURE) | |
{ | |
'x86' {$AzureModulePath = "$env:ProgramFiles\Microsoft SDKs\Azure\powershell\ServiceManagement\Azure\Azure.psd1"} | |
'AMD64' {$AzureModulePath = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\powershell\ServiceManagement\Azure\Azure.psd1"} | |
} | |
### Create a Cim session to PS01v for printer operations | |
$CimPs01 = New-CimSession -ComputerName ps01 -Credential $SAMMattAdmin | |
### set default values for commonly used parameters | |
. "$PSScriptRoot\PSDefaultParameterValues.ps1" | |
### Customize the ISE | |
if ($psise) | |
{ | |
Import-Module ISELibrary | |
. "$PSScriptRoot\ISEConfig.ps1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$psISE.options.SelectedScriptPaneState = 'Maximized' | |
$psISE.Options.ShowDefaultSnippets = $false | |
Import-IseSnippet -Path "$Dirscripts\Snippets\" -Recurse | |
### Load Add-ons | |
. "$PSScriptRoot\load-addons.ps1" | |
Remove-ISEUntitled | |
Import-ISEEditorState -Path "$Dirscripts\temp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$psTab = $psISE.CurrentPowerShellTab.addonsmenu | |
$IseLibrary = $psTab.Submenus.Add('IseLibrary',$null,$null) | |
$null = $IseLibrary.Submenus.Add('Toggle Font',{Switch-ISEFont},'Ctrl+Alt+F') | |
$null = $IseLibrary.Submenus.Add('Toggle Font',{Switch-ISEFontSize},'Ctrl+Alt+S') | |
$null = $IseLibrary.Submenus.Add('Remove Trailing Blanks', {Remove-TrailingBlanks}, 'Ctrl+Alt+T') | |
$null = $IseLibrary.Submenus.Add('Remove Blank Lines', {Remove-BlankLines}, 'Ctrl+Alt+B') | |
$null = $IseLibrary.Submenus.Add('Save Editor State and Exit',{Save-ISEEditorStateAndExit},'Ctrl+Alt+E') | |
Remove-Variable -Name psTab, IseLibrary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Import Credentials | |
$SAMMattAdmin = (Import-Clixml "$DirScripts\Creds\cred_SAM_mattadmin_$Env:ComputerName.xml") | |
$UPNattAdmin = (Import-Clixml "$DirScripts\Creds\cred_UPN_mattadmin_$Env:ComputerName.xml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Extend the module path to include Onedrive folder | |
$Env:PSModulePath = $Env:PSModulePath -replace 'c:\\Users\\matt\\My Documents\\WindowsPowerShell\\Modules','' | |
$Env:PSModulePath += ";$DirScripts\Modules" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Custom prompt | |
. "$PSScriptRoot\prompt.ps1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-LastExecutionTime | |
{ | |
$LastCmd = Get-History -Count 1 | |
$ExecTime = $LastCmd.EndExecutionTime - $LastCmd.StartExecutionTime | |
'{0:00}:{1:00}:{2:00}' -f $ExecTime.Minutes, $ExecTime.Seconds, $ExecTime.Milliseconds | |
} | |
function prompt { | |
if (((get-location).path).length -gt 40) | |
{ | |
Write-Host "$(Get-Location)" -NoNewline -ForegroundColor Yellow | |
Write-Host "[$(Get-LastExecutionTime)]" -ForegroundColor Green | |
Write-Host $('>' * ($NestedPromptLevel + 1)) -NoNewline -ForegroundColor Green | |
return ' ' | |
} | |
else | |
{ | |
Write-Host "$(Get-Location)" -NoNewline -ForegroundColor yellow | |
Write-Host "[$(Get-LastExecutionTime)]" -NoNewline -ForegroundColor Green | |
Write-Host $('>' * ($NestedPromptLevel + 1)) -NoNewline -ForegroundColor Green | |
return ' ' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Import commonly used modules | |
Import-Module ActiveDirectory | |
Import-Module ADLibrary | |
Import-Module MSOLLibrary | |
Import-Module ServerAdminLibrary | |
Import-Module GeneralLibrary | |
switch ($Env:PROCESSOR_ARCHITECTURE) | |
{ | |
'x86' {$AzureModulePath = "$env:ProgramFiles\Microsoft SDKs\Azure\powershell\ServiceManagement\Azure\Azure.psd1"} | |
'AMD64' {$AzureModulePath = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\powershell\ServiceManagement\Azure\Azure.psd1"} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Create a Cim session to PS01v for printer operations | |
$CimPs01 = New-CimSession -ComputerName ps01 -Credential $SAMMattAdmin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### set default values for commonly used parameters | |
. "$PSScriptRoot\PSDefaultParameterValues.ps1" | |
{% endhighlight %} | |
{% highlight Powershell %} | |
$PSDefaultParameterValues = @{ | |
'Get-Printer:CimSession' = $Cimps01 | |
'Get-PrinterDriver:CimSession' = $Cimps01 | |
'Get-PrinterPort:CimSession:CimSession' = $Cimps01 | |
'Export-Csv:NoTypeInformation' = $true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Customize the ISE | |
if ($psise) | |
{ | |
Import-Module ISELibrary | |
. "$PSScriptRoot\ISEConfig.ps1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment