This file contains hidden or 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
| <# | |
| If you create enums and/or custom attributes and want to reuse them, you would (or at least, I did) think that they should go into psm1 module files and be included in other modules via the NestedModules line of the module manifest. | |
| BUT YOU WOULD BE (or at least, I was) WRONG! | |
| Instead, create them in .ps1 script files and add them to the ScriptsToProcess line of the module manifest. | |
| And if you use the enum directly in Pester tests, you will need to run the enum script file there, too, as they do not persist between scripts (as noted here: https://tfl09.blogspot.com/2014/11/enums-in-powershell-v5.html). | |
| That said, if you follow this advice for enums (is it that the enums are in ScriptsToProcess, or anything? I haven't tested), you may need to refactor classes into THEIR own psm1 files. But in so doing, you may break Get-Help and intellisense for functions that take objects of those classes as parameters. At which point you may wind up with all the Enums and Classes back in the main psm1 file(s). | |
| By way of |
This file contains hidden or 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 your PowerShell execution policy | |
| Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force | |
| function Invoke-ComputerSetup { | |
| [CmdletBinding(DefaultParameterSetName='Parameter Set 1', | |
| SupportsShouldProcess=$true, | |
| PositionalBinding=$false, |
This file contains hidden or 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
| <# | |
| .Synopsis | |
| Rough PS functions to create new user profiles | |
| .DESCRIPTION | |
| Call the Create-NewProfile function directly to create a new profile | |
| .EXAMPLE | |
| Create-NewProfile -Username 'testUser1' -Password 'testUser1' | |
| .NOTES | |
| Created by: Josh Rickard (@MS_dministrator) and Thom Schumacher (@driberif) |
This file contains hidden or 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
| <# | |
| .SYNOPSIS | |
| Replace tokens in a file with values. | |
| .DESCRIPTION | |
| Finds tokens in a given file and replace them with values. It is best used to replace configuration values in a release pipeline. | |
| .PARAMETER InputFile | |
| The file containing the tokens. |
This file contains hidden or 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
| primary: | |
| background: '#181818' | |
| foreground: '#C7C7C7' | |
| normal: | |
| black: '#000000' | |
| red: '#CD3131' | |
| green: '#0DBC79' | |
| yellow: '#E5E510' | |
| blue: '#2472C8' | |
| magenta: '#BC3FBC' |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Management.Automation.Language; | |
| public class ScriptExtent : IScriptExtent | |
| { | |
| private readonly IScriptPosition _start; | |
| private readonly IScriptPosition _end; |
This file contains hidden or 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
| #requires -version 7.2 | |
| <# | |
| These commands can be used to export FileInfo settings from $PSStyle and | |
| then import them in another session. You might use the import command in | |
| your PowerShell profile script. The file must be a json file. | |
| #> | |
| Function Export-PSStyleFileInfo { | |
| [cmdletbinding(SupportsShouldProcess)] | |
| Param( |
This file contains hidden or 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
| # From https://technet.microsoft.com/en-us/library/ff730944.aspx | |
| # This will open an internet explorer window that will display all installed windows font names in their corresponding font. | |
| [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | |
| $objFonts = New-Object System.Drawing.Text.InstalledFontCollection | |
| $colFonts = $objFonts.Families | |
| $objIE = New-Object -com "InternetExplorer.Application" | |
| $objIE.Navigate("about:blank") | |
| $objIE.ToolBar = 0 |
This file contains hidden or 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
| using namespace System.Collections.Generic | |
| # Encapsulate an arbitrary command | |
| class PaneCommand { | |
| [string]$Command | |
| PaneCommand() { | |
| $this.Command = ""; | |
| } |
This file contains hidden or 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
| # | |
| # Working with branches | |
| # | |
| # Get the current branch name (not so useful in itself, but used in | |
| # other aliases) | |
| branch-name = "!git rev-parse --abbrev-ref HEAD" | |
| # Push the current branch to the remote "origin", and set it to track | |
| # the upstream branch | |
| publish = "!git push -u origin $(git branch-name)" |