full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/PowerShellGallery/MrAAzure/1.8.1/Copy-AzureItem.ps1
Copy-AzureItem.ps1
function Copy-AzureItem { <# .SYNOPSIS This function simplifies the process of uploading files to an Azure storage account. In order for this function to work you must have already logged into your Azure subscription with Login-AzureAccount. The file uploaded will be called the file name as the storage bl...
PowerShellCorpus/PowerShellGallery/MrAAzure/1.8.1/Install-AzureRmVMExtensionLegacy.ps1
Install-AzureRmVMExtensionLegacy.ps1
<# .Synopsis Install-AzureRmVmExtension simplifies the process of installing VM extensions on Azure IaaS resource manager VM's. .DESCRIPTION Install-AzureRmVmExtension simplifies the process of installing VM extensions on Azure IaaS resource manager VM's. .NOTES Created by: Jason Wasser @wasser...
PowerShellCorpus/PowerShellGallery/AzureRM.RecoveryServices/3.1.0/AzureRmRecoveryServicesStartup.ps1
AzureRmRecoveryServicesStartup.ps1
# ---------------------------------------------------------------------------------- # # Copyright Microsoft Corporation # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apach...
PowerShellCorpus/PowerShellGallery/Await/0.8/Tests/Await.Tests.ps1
Await.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path Describe "Basics" { It "Doesn't leak processes" { $beforeProcesses = Get-Process -Name PowerShell Start-AwaitSession do { $midProcesses = Get-Process -Name PowerShell } while($midProcesses.Coun...
PowerShellCorpus/PowerShellGallery/xPrinter/1.0.0.1/DSCResources/xPrinter/%E6%97%A0%E6%A0%87%E9%A2%981.ps1
%E6%97%A0%E6%A0%87%E9%A2%981.ps1
$Printername = New-xDscResourceProperty -Name PrinterName -Type String -Attribute Key -Description "要添加的打印机" $PrinterPort = New-xDscResourceProperty -Name PrinterPort -Type String -Attribute Required -Description "要添加的打印机端口" $PortIP = New-xDscResourceProperty -Name PortIP -Type String -Attribute Required -Descriptio...
PowerShellCorpus/PowerShellGallery/xPrinter/1.0.0.1/DSCResources/xPrinter/DSCPrinter.ps1
DSCPrinter.ps1
Configuration Printer { node LocalHost { xPrinter A { Ensure = "present" PortIP = "192.168.2.1" PrinterPort = "Publicx" PrinterName = "XX" DirverName = "Canon iR2002/2202 UFRII LT" } } } Co...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/install.ps1
install.ps1
Write-Host -Object 'Installing ISESteroids' $version = $PSVersionTable.PSVersion.Major if ($version -lt 3) { Write-Warning 'ISESteroids requires PowerShell 3 or better.' Write-Warning "Your current PowerShell version is $version." return } $isepath = Join-Path -Path $pshome -ChildPath 'powershell_is...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Pester/defaultheader.tests.ps1
defaultheader.tests.ps1
# this is a Pester test file #region Further Reading # http://www.powershellmagazine.com/2014/03/27/testing-your-powershell-scripts-with-pester-assertions-and-more/ #endregion #region LoadScript # load the script file into memory # attention: make sure the script only contains function definitions # and no act...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Pester/default.tests.ps1
default.tests.ps1
# describes the function {0} Describe '{0}' { # scenario 1: call the function without arguments Context 'Running without arguments' { # test 1: it does not throw an exception: It 'runs without errors' { # Gotcha: to use the "Should Not Throw" assertion, # make sure you place the comma...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/TemplateScripts/XAML/Create XAML Action Table.ps1
Create XAML Action Table.ps1
# nachladen von WPF (nötig für powershell.exe, weil hier # anders als in der ISE die WPF Bibliotheken nicht # automatisch geladen werden: Add-Type -AssemblyName PresentationFramework $xaml = @" <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micros...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/TemplateScripts/XAML/Display XAML.ps1
Display XAML.ps1
# nachladen von WPF (nötig für powershell.exe, weil hier # anders als in der ISE die WPF Bibliotheken nicht # automatisch geladen werden: Add-Type -AssemblyName PresentationFramework $xaml = @" <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.micros...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/WPFSamples/Full Examples/Dialog with Textboxes.ps1
Dialog with Textboxes.ps1
#region XAML window definition # Right-click XAML and choose WPF/Edit... to edit WPF Design # in your favorite WPF editing tool $xaml = @' <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MinWidth="200" Width ="400" ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/WPFSamples/Full Examples/Dropdown list and data binding.ps1
Dropdown list and data binding.ps1
#region XAML window definition # Right-click XAML and choose WPF/Edit... to edit WPF Design # in your favorite WPF editing tool $xaml = @' <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MinWidth="200" Width ="400" ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/FixerOnDemand/Fix Content/Convert String To Variable/ConvertTextToEnvironmentVariable.ps1
ConvertTextToEnvironmentVariable.ps1
# replaces literal strings with environment variables where appropriate & { function GetBestMatch($Text) { foreach($environmentString in $lookup) { if ($Text -match ([RegEx]::Escape($environmentString.Value) + '\b')) { return $environmentString } } } # g...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/PSSharper/Syntax/MissingExpressionAfterToken.ps1
MissingExpressionAfterToken.ps1
param($StartOffset,$Length,$Ast) # is the error at the very end of the file? $isEnd = $Ast.Extent.EndOffset - ($StartOffset + $Length) -lt 1 # then move the insertion point one to the right if (!$isEnd) { $StartOffset-- } # is it inside a hash? $hash = $AST.FindAll({$args[0] -is [System.Management.Automat...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/PSSharper/Syntax/MissingEndParenthesisInMethodCall.ps1
MissingEndParenthesisInMethodCall.ps1
param($StartOffset,$Length,$Ast) # is the error at the very end of the file? $isEnd = $Ast.Extent.EndOffset - ($StartOffset + $Length) -lt 1 # then move the insertion point one to the right if ($isEnd) { $StartOffset++ } # add a closing parenthesis return New-Object -TypeName ISESteroids.PSSharper.FixInform...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/PSSharper/Syntax/MissingEndParenthesisInFunctionParameterList.ps1
MissingEndParenthesisInFunctionParameterList.ps1
param($StartOffset,$Length,$Ast) # add a comma return New-Object -TypeName ISESteroids.PSSharper.FixInformation($StartOffset, ',')
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Quality Improvement/DoubleQuotes/DoubleQuotes.ps1
DoubleQuotes.ps1
& { Set-StrictMode -Off # fixes double quoted strings that do not really need double quotes $Strings = [ISESteroids.SteroidsFixer.Helpers]::GetAST('DoubleQuotedString') foreach($string in $strings) { if ($string.Extent.Text -notmatch '[$`'']') { $text = $string.Extent.Text.SubString(1) $text...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Final Touches/Requires/AddRequirements.ps1
AddRequirements.ps1
& { # do not update #requires statement for .psm1 files $extension = [IO.Path]::GetExtension($psise.PowerShellTabs.SelectedPowerShellTab.Files.SelectedFile.FullPath) if ($extension -ne '.psm1') { $editor = Get-SteroidsEditor Update-SteroidsRequiresStatement -ISEEditor $editor } Invoke-SteroidsTextChan...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Spaces/OperatorAdjustSpace/OperatorAdjustSpace.ps1
OperatorAdjustSpace.ps1
& { $unary = [Management.Automation.Language.TokenFlags]::UnaryOperator $info = Get-SteroidsAST $tokenCount = $info.TokenList.Count # we need a minimum of three tokens for this test if ($tokenCount -ge 3) { for ($i=1; $i -lt $tokenCount-1; $i++) { $token = $info.TokenLis...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Spaces/ArrayAdjustSpace/ArrayAdjustSpace.ps1
ArrayAdjustSpace.ps1
& { # get all ArrayLiteralASTs $items = [ISESteroids.SteroidsFixer.Helpers]::GetAST('Array') foreach($item in $items) { $tokenlist = [ISESteroids.SteroidsFixer.Helpers]::GetToken($item.Extent.StartOffset, $item.Extent.EndOffset) $tokenCount = $tokenlist.Count for($i=0; $i-lt$tokenCount-1;$i++) { ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/ScriptBlock/ScriptBlockRemoveEmptyLines/ScriptBlockRemoveEmptyLines.ps1
ScriptBlockRemoveEmptyLines.ps1
& { Set-StrictMode -Off # removes any empty (blank) line that is positioned # - between opening brace and content # - between content and closing brace $crlf = -join [Char[]](13,10) $items = [ISESteroids.SteroidsFixer.Helpers]::GetAST('ScriptAndStatementblock') foreach($ScriptBlock in $items) { ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/ScriptBlock/ScriptBlockAlignBracesSome/ScriptBlockAlignBracesSome.ps1
ScriptBlockAlignBracesSome.ps1
& { # purpose is to reformat scriptblocks # scriptblocks are a common element in many PowerShell structures # and can also be used standalone # to improve readability, this unit identifies the opening and # closing braces and makes sure these braces exist on individual lines # separated from other conten...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/ScriptBlock/ScriptBlockAlignBracesAll/ScriptBlockAlignBracesAll.ps1
ScriptBlockAlignBracesAll.ps1
& { Set-StrictMode -Off # purpose is to reformat scriptblocks # scriptblocks are a common element in many PowerShell structures # and can also be used standalone # to improve readability, this unit identifies the opening and # closing braces and makes sure these braces exist on individual lines # separ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Character Operations/Illegal Characters/IllegalCharacters.ps1
IllegalCharacters.ps1
# Replaces individual ASCII and UNICODE characters # use this to change illegal characters # illegal characters may be introduced when scripts are copied from # web pages or text editors, and typographic changes were made & { # get access to the editor: $Editor = Get-SteroidsEditor # get script conten...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Character Operations/BacktickPlusSpace/BacktickSpace.ps1
BacktickSpace.ps1
# makes sure all lines end CRLF (ASCII code 13 and 10) & { # makes sure all lines end CRLF (ASCII code 13 and 10) & { # get access to editor: $Editor = Get-SteroidsEditor # RegEx pattern for various types of line endings: $pattern = '(?m)\`\s{1,}$' # find these line e...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Character Operations/NormalizeLineEndings/NormalizeLineEndings.ps1
NormalizeLineEndings.ps1
# makes sure all lines end CRLF (ASCII code 13 and 10) & { # get access to editor: $Editor = Get-SteroidsEditor # RegEx pattern for various types of line endings: $pattern = '\r\n|\n\r|\n|\r' # find these line endings and replace them with a normalized line ending: [Regex]::Matches($Editor.text,...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Command/CommandPositionalParameter/CommandPositionalParameter.ps1
CommandPositionalParameter.ps1
& { Set-StrictMode -Off $commands = @{} # get all commands available foreach($command in (Get-Command -CommandType Function, Cmdlet)) { # add each unique command to a hash table $name = $command.Name if ($commands.ContainsKey($name) -eq $false) { $commands.Add($name, $com...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Command/CommandCase/CommandCase.ps1
CommandCase.ps1
# Case-corrects command names & { # array that holds all known command names: $commands = @{} # include all functions that are defined in the script $items = [ISESteroids.SteroidsFixer.Helpers]::GetAST('Function') # add each function that is defined in the script foreach($item in $items) ...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Command/CommandParameter/CommandParameter.ps1
CommandParameter.ps1
# Case-correct command parameter names & { # array that will hold all commands that are going to be fixed: $commands = @{} # get all functions and cmdlets (these command types use Powershell-style parameters): foreach($command in (Get-Command -CommandType Function, Cmdlet)) { $n...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Command/ReplaceAliases/ReplaceAliases.ps1
ReplaceAliases.ps1
# searches for Aliases and replaces them with the underlying # original command & { Set-StrictMode -Off # get access to the AST (abstract syntax tree): $info = Get-SteroidsAST # find commands in the script: $Commands = $info.Ast.FindAll({ $args[0] -is [System.Management.Automation.Language.Comma...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Pipeline/PipelineBreakAfterPipe/PipelineBreakAfterPipe.ps1
PipelineBreakAfterPipe.ps1
& { $crlf = -join [Char[]](13,10) $items = [ISESteroids.SteroidsFixer.Helpers]::GetAST('Pipeline') foreach($item in $items) { # do optimization only with 3 or more pipeline elements if ($item.PipelineElements.Count -le 2) { continue } $tokenList = [ISESteroids.SteroidsFixer.Helpers]::GetToken($item....
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Pipeline/PipelineRemoveOutNull/PipelineRemoveOutNull.ps1
PipelineRemoveOutNull.ps1
& { $items = [ISESteroids.SteroidsFixer.Helpers]::GetAST('Pipeline') foreach($item in $items) { if ($item.PipelineElements[-1].Extent.Text -eq 'Out-Null') { # remove last pipeline element [ISESteroids.SteroidsFixer.Helpers]::AddTextChange($item.PipelineElements[-2].Extent.EndOffset, $item.PipelineEl...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Reformat Structures/Reformat Hashtable/ReformatHashtable.ps1
ReformatHashtable.ps1
& { foreach($hashtable in [ISESteroids.SteroidsFixer.Helpers]::GetAST('Hashtable')) { if ($hashtable.Extent.Text.TrimStart().StartsWith('@') -eq $false -or $hashtable.KeyValuePairs.Count -eq 0) { continue } $sb = New-Object -TypeName System.Text.StringBuilder $null = $sb.AppendLine('@{') # find ma...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Reformat Structures/RemoveSemicolon/RemoveSemicolon.ps1
RemoveSemicolon.ps1
& { $info = Get-SteroidsAST $Tokens = $info.TokenList $i = $Tokens.Count for($x=0; $x -lt $i; $x++) { # is this a semicolon? if ($Tokens[$x].Kind -eq 'Semi') { # is this token inside a structure where semicolons are useful? $DoReplace = Test-SteroidsTextChange -Extent $Tokens[$x].Extent -A...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Fixer/Variables/NormalizeVariables/NormalizeVariables.ps1
NormalizeVariables.ps1
& { $variables = [ISESteroids.SteroidsFixer.Helpers]::GetAST('VariableExpression') $lookup = @{} foreach($variable in $variables) { if ($variable.Extent.Text.StartsWith('$') -or $variable.Extent.Text.StartsWith('@')) { $name = $variable.VariablePath.toString() if ($variable.Splat...
PowerShellCorpus/PowerShellGallery/ISESteroids/2.6.3.30/Templates/Generic Header.ps1
Generic Header.ps1
<# Author: Version: Version History: Purpose: #>
PowerShellCorpus/PowerShellGallery/PesterMatchHashtable/0.0.1/RunPester.ps1
RunPester.ps1
function GetLineNumber($stackTrace){ if($stackTrace -match "at line: (\d*)"){ $matches[1]; } else { $null } } function GetFileName($stackTrace){ if($stackTrace -match "at line: (?:\d*) in (.*)$"){ $matches[1]; } else { $null } } function FormatResult ($result){ process { $lineNumber = ...
PowerShellCorpus/PowerShellGallery/PesterMatchHashtable/0.0.1/Publish.ps1
Publish.ps1
Param( [Parameter(Mandatory=$true)] [string]$powershellGalleryKey ) Publish-Module -NuGetApiKey $powershellGalleryKey -Path ./
PowerShellCorpus/PowerShellGallery/PesterMatchHashtable/0.0.1/Examples.ps1
Examples.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path Import-Module "$here\PesterMatchHashtable.psm1" -Force Describe "MatchHashtable examples" { It "single item hashtables match" { @{"a"=1} | Should MatchHashtable @{"a"=1} } It "hashtables with the same contents match" { @{"a"=1;"b"...
PowerShellCorpus/PowerShellGallery/PesterMatchHashtable/0.0.1/PesterMatchHashtable.Tests.ps1
PesterMatchHashtable.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".") . "$here\$sut" ## Test Assertion functions takenb from: https://github.com/pester/Pester/blob/ebfb0997365fea29f25b2aa3065378a3765eff4c/Functions/Assertions/Test-Assertion.ps1 fu...
PowerShellCorpus/PowerShellGallery/PesterMatchHashtable/0.0.1/PesterMatchHashtable.ps1
PesterMatchHashtable.ps1
function PesterMatchHashtable($value, $expectedMatch) { # Write-Host "foo: $(ConvertTo-Json $value); $(ConvertTo-Json $expectedMatch)" if($value.Count -ne $expectedMatch.Count){ return $false; } foreach($expectedKey in $expectedMatch.Keys) { if (-not($value.Keys -contains $expected...
PowerShellCorpus/PowerShellGallery/Azure.ToolKit/1.3/PSScriptAnalyzer.ps1
PSScriptAnalyzer.ps1
# To get latest PSScriptAnalyzer run # Install-Module -Name PSScriptAnalyzer Import-Module PSScriptAnalyzer -Force Invoke-ScriptAnalyzer -Path $PSScriptRoot -Recurse
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/GetModuleExtension.ps1
GetModuleExtension.ps1
function Get-ModuleExtension { [CmdletBinding()] param( [string] $ModuleName, [Version] $ModuleVersion ) $modules = Get-Module -ListAvailable Write-Verbose "`nFound $($modules.Length) installed modules to scan for extensions." function ParseVersion($versionStri...
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/InvokePlaster.ps1
InvokePlaster.ps1
## DEVELOPERS NOTES & CONVENTIONS ## ## 1. All text displayed to the user except for Write-Debug (or $PSCmdlet.WriteDebug()) text must be added to the ## string tables in: ## en-US\Plaster.psd1 ## Plaster.psm1 ## 2. If a new manifest element is added, it must be added to the Schema\PlasterManifest...
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/NewPlasterManifest.ps1
NewPlasterManifest.ps1
function New-PlasterManifest { [CmdletBinding(SupportsShouldProcess=$true)] param( [Parameter()] [ValidateNotNullOrEmpty()] [string] $Path = "$pwd\plasterManifest.xml", [Parameter(Mandatory=$true)] [ValidatePattern('^[0-9a-zA-Z_-]+$')] [string] $T...
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/TestPlasterManifest.ps1
TestPlasterManifest.ps1
function Test-PlasterManifest { [CmdletBinding()] [OutputType([System.Xml.XmlDocument])] param( [Parameter(Position=0, ParameterSetName="Path", ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, HelpMessage="Spe...
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/GetPlasterTemplate.ps1
GetPlasterTemplate.ps1
. $PSScriptRoot\GetModuleExtension.ps1 function Get-PlasterTemplate { [CmdletBinding()] param( [Parameter(Position=0, ParameterSetName="Path", HelpMessage="Specifies a path to a folder containing a Plaster template or multiple template folders. Can also be a path ...
PowerShellCorpus/PowerShellGallery/Plaster/1.0.1/Templates/NewPowerShellManifestModule/test/Module.T.ps1
Module.T.ps1
$ModuleManifestName = '<%=$PLASTER_PARAM_ModuleName%>.psd1' $ModuleManifestPath = "$PSScriptRoot\..\$ModuleManifestName" Describe 'Module Manifest Tests' { It 'Passes Test-ModuleManifest' { Test-ModuleManifest -Path $ModuleManifestPath $? | Should Be $true } }
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Write-JojobaFail.ps1
Write-JojobaFail.ps1
<# .SYNOPSIS Mark a Jojoba test as failed. .DESCRIPTION Jojoba tests pass by default, but they can fail, or be skipped. .PARAMETER Message A string. This should be a simple, short sentence, detailing exactly what has failed. Multiple failures will have their messages combined with newlines. A message must b...
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Write-JojobaSkip.ps1
Write-JojobaSkip.ps1
<# .SYNOPSIS Mark a Jojoba test as skipped. .DESCRIPTION Jojoba tests pass by default, but they can fail, or be skipped. .PARAMETER Message A string. This should be a simple, short sentence, detailing exactly what has been skipped or why. Multiple skips will have their messages combined with newlines. A mes...
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Write-JojobaXml.ps1
Write-JojobaXml.ps1
<# .SYNOPSIS Converts Jojoba test case objects to a jUnit XML file Jenkins can understand. .DESCRIPTION Jenkins is best used with a jUnit XML file to provide further information on why tests have passed, failed, or been skipped. This function provides that translation. .PARAMETER Test One or more Jojoba tes...
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Publish-Jojoba.ps1
Publish-Jojoba.ps1
<# .SYNOPSIS Retrieve results from Jojoba parallel runs and optionally package them for Jenkins. .DESCRIPTION For a Jojoba template function a call to Publish-Jojoba must be in the end {} block. If parallel processing has been used, this script will wait for all jobs to complete before outputting the test data....
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Start-Jojoba.ps1
Start-Jojoba.ps1
<# .SYNOPSIS Parallel processing with test case output and Jenkins integration. .DESCRIPTION For a Jojoba template function this will be the main call in the process {} block. All processing should occur within here. .PARAMETER ScriptBlock The test to carry out. It must use $InputObject or $_. .INPUTS ...
PowerShellCorpus/PowerShellGallery/Jojoba/1.4.0.3/Out-JojobaSpeech.ps1
Out-JojobaSpeech.ps1
<# .SYNOPSIS Read out basic Jojoba results to a sound card. .DESCRIPTION Takes a Jojoba result and reads out each class, name, and result (and optional message). It will repeat failures twice. .PARAMETER Test A Jojoba test case. .PARAMETER VoiceGender Male or Female. .PARAMETER VoiceRate Rate of spe...
PowerShellCorpus/PowerShellGallery/ExifDateTime/1.0/PublishPsGalleryModule.ps1
PublishPsGalleryModule.ps1
#requires -Modules PowerShellGet Param ( [Parameter(Mandatory)] $PsGalleryApiKey ) $ReleaseNotes =@' ExifDateTime Chris Warwick, @cjwarwickps, August 2013 This version: November 2015 The module contains two functions: Get-ExifDateTaken -Path <filepaths> Takes a file (fileinfo or s...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/Get-LegacyNetAdapterConfiguration.ps1
Get-LegacyNetAdapterConfiguration.ps1
function Get-LegacyNetAdapterConfiguration { [CmdletBinding(DefaultParameterSetName = 'Default')] [OutputType([System.Management.ManagementObject])] param ( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Default')] [System.String] $Name, ...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/Remove-LegacyNetFirewallRule.ps1
Remove-LegacyNetFirewallRule.ps1
function Remove-LegacyNetFirewallRule { [CmdletBinding(SupportsShouldProcess)] param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Alias('Name')] [System.String] $DisplayName, [Parameter(Mandatory, ValueFromPipelin...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/New-LegacyNetFirewallRule.ps1
New-LegacyNetFirewallRule.ps1
function New-LegacyNetFirewallRule { [CmdletBinding(DefaultParameterSetName = 'Default', SupportsShouldProcess)] [OutputType([System.Management.Automation.PSCustomObject])] param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Ali...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/Get-LegacyNetAdapter.ps1
Get-LegacyNetAdapter.ps1
function Get-LegacyNetAdapter { [CmdletBinding(DefaultParameterSetName = 'Default')] [OutputType([System.Management.ManagementObject])] param ( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [System.String] $Name, [Parameter(ValueFromPipelineByPropert...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/Set-LegacyNetFirewallRule.ps1
Set-LegacyNetFirewallRule.ps1
function Set-LegacyNetFirewallRule { [CmdletBinding(DefaultParameterSetName = 'Default', SupportsShouldProcess)] [OutputType([System.Management.Automation.PSCustomObject])] param ( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [Ali...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Src/Get-LegacyNetFirewallRule.ps1
Get-LegacyNetFirewallRule.ps1
function Get-LegacyNetFirewallRule { [CmdletBinding(DefaultParameterSetName = 'Default')] [OutputType([System.Management.Automation.PSCustomObject])] param ( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] #[Parameter(ParameterSetName = 'Port',...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/ConvertTo-CIDR.ps1
ConvertTo-CIDR.ps1
function ConvertTo-CIDR { [CmdletBinding()] [OutputType([System.String])] param ( [Parameter(Mandatory, ValueFromPipeline)] [System.String] $SubnetMask ) $SubnetMask -split '\.' | ForEach-Object { $subnet = $subnet * 256 + [System.Convert]::ToInt64($_); } return [System...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/Remove-DuplicateMembers.ps1
Remove-DuplicateMembers.ps1
<# The MIT License (MIT) Copyright (c) 2015 Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation t...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/Resolve-ProfileParameter.ps1
Resolve-ProfileParameter.ps1
function Resolve-ProfileParameter { [CmdletBinding()] [OutputType([System.String[]])] param ( [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('Public','Private','Domain','Any')] [System.String[]] $Profile ) process { $dedupedProfiles = Remove-DuplicateMember...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/Test-Members.ps1
Test-Members.ps1
<# The MIT License (MIT) Copyright (c) 2015 Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation t...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/Get-NetshFirewallRule.ps1
Get-NetshFirewallRule.ps1
function Get-NetshFirewallRule { [CmdletBinding()] [OutputType([System.String[]])] param ( [Parameter(ValueFromPipeline)] [ValidateNotNullOrEmpty()] [System.String] $DisplayName, [Parameter(ValueFromPipelineByPropertyName)] [ValidateSet('Public','Private','Domain')] ...
PowerShellCorpus/PowerShellGallery/LegacyNetworking/1.0.1/Lib/ConvertFrom-CIDR.ps1
ConvertFrom-CIDR.ps1
function ConvertFrom-CIDR { [CmdletBinding()] [OutputType([System.String])] param ( [Parameter(Mandatory, ValueFromPipeline)] [Uint32] $CIDR ) ## Convert CIDR to netmask $int64 = ([System.Convert]::ToInt64(('1'*$CIDR + '0'*(32-$CIDR)), 2)); return '{0}.{1}.{2}.{3}' -...
PowerShellCorpus/PowerShellGallery/Disposable/1.4.0.3/New-DisposableObject.ps1
New-DisposableObject.ps1
<# .SYNOPSIS Dispose disposable variables, the equivalent of C# using for PowerShell. .DESCRIPTION Objects which own unmanaged resources (such as network connections and SQL Server database connections) should have their Dispose method called in order to free up those connections and so the object's memory can ...
PowerShellCorpus/PowerShellGallery/Timezone/1.2.2/Timezone.Tests.ps1
Timezone.Tests.ps1
#Requires -Module Pester if ((Get-Module).Name -contains 'Timezone') { Remove-Module -Name Timezone } Import-Module "$PSScriptRoot\Timezone.psm1" InModuleScope Timezone { Describe 'Get-Timezone' { Context 'UTC' { It 'Returns the current Timezone object' { $time...
PowerShellCorpus/PowerShellGallery/Timezone/1.2.2/Timezone.Help.Tests.ps1
Timezone.Help.Tests.ps1
<# .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119 Created on: 4/12/2016 1:11 PM Created by: June Blender Organization: SAPIEN Technologies, Inc Filename: *.Help.Tests.ps1 =======...
PowerShellCorpus/PowerShellGallery/AutoPatchDSC/1.4.2/Write-AutoPatchLog.ps1
Write-AutoPatchLog.ps1
#write log with verbose option Function Write-AutoPatchLog { [CmdletBinding()] param ( [Parameter(Mandatory=$True, Position=1)] [ValidateNotNullOrEmpty()] [string] $message, [string] $logFile = $Global:AutoPatchDSCLogFile, [switch] $writeError, [switc...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/src/Import-ModuleFromPath.ps1
Import-ModuleFromPath.ps1
#Requires -Version 3.0 <# .Synopsis Re-Imports a module from the given path. .DESCRIPTION The function can be used in a Pester test script to load a module from the developer path by removing all already loaded modules with the same name. .EXAMPLE Import-ModuleFromPath . Re...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/tests/TestHelper.ps1
TestHelper.ps1
function New-TestModule { Param([string] $Name) # The actual module folder $moduleFolder = New-Item -Path "${TestDrive}\${Name}" -ItemType Directory # The corresponding module.psm1 file New-Item -Path "${moduleFolder}\${Name}.psm1" -ItemType File | Out-Null Write-Output $moduleFolder ...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/tests/TestHelper.Meta.Tests.ps1
TestHelper.Meta.Tests.ps1
#Requires -Modules Pester $sut = 'TestHelper' . "${PSScriptRoot}\${sut}.ps1" Describe "'New-TestModule' tests" { $path = New-TestModule 'mymodule' AfterAll { Get-Module 'mymodule' -All | Remove-Module -Force } It "should exist the module folder" { $path | Should exis...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/tests/DummyModule.Tests.ps1
DummyModule.Tests.ps1
#Requires -Modules Pester $testingModule = Get-Item -Path "${PSScriptRoot}\..\..\testing" Get-Module -Name testing -All | Remove-Module -Force Import-Module $testingModule -Force -ErrorAction Stop Import-ModuleFromPath -Path "${PSScriptRoot}\DummyModule" Describe "Calling method from DummyModule when impor...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/tests/Import-ModuleFromPath.Tests.ps1
Import-ModuleFromPath.Tests.ps1
#Requires -Modules Pester . $PSScriptRoot\TestHelper.ps1 $module = 'testing' $sut = 'Import-ModuleFromPath' $path = Split-Path -Path $PSScriptRoot -Parent Get-Module -Name $module -All | Remove-Module -Force Import-Module $path -Force -ErrorAction Stop Describe "'$sut' tests with valid module folder" { ...
PowerShellCorpus/PowerShellGallery/testing/0.1.1/tests/DummyModule/test/DummyModule.Tests.ps1
DummyModule.Tests.ps1
#Requires -Modules Pester $testingModule = Get-Item -Path "${PSScriptRoot}\..\..\..\..\testing" Get-Module -Name testing -All | Remove-Module -Force Import-Module $testingModule -Force -ErrorAction Stop Import-ModuleFromPath -Parent Describe "Calling method from DummyModule when imported via Parent paramet...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/TestSampleUsingAzure.ps1
TestSampleUsingAzure.ps1
# To Run this test create a Windows Server 2012 or 2012 R2 VM in Azure # and run this script. It will prompt you to choose a VM, choose the VM. # wait a while, RDP into the machine and manually verify that the DHCP Server # is configured as specified in .\samples\SampleConfiguration.ps1 Write-Verbose -Message 'P...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Misc/New-DhcpServerOptionResource.ps1
New-DhcpServerOptionResource.ps1
$Properties = @{ DnsServer = New-xDscResourceProperty -Name DnsServerIPAddress -Type String[] -Attribute Required ` -Description 'IP address of DNS Servers' Router = New-xDscResourceProperty -Name Router -Type String[] -Attribute Required ` ...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Misc/New-DhcpServerScopeResource.ps1
New-DhcpServerScopeResource.ps1
$Properties = @{ ScopeID = New-xDscResourceProperty -Name ScopeID -Type String -Attribute Read ` -Description 'ScopeId for which properties are set' Name = New-xDscResourceProperty -Name Name -Type String -Attribute Required ` ...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Misc/New-DhcpServerReservationResource.ps1
New-DhcpServerReservationResource.ps1
$Properties = @{ ScopeID = New-xDscResourceProperty -Name ScopeID -Type String -Attribute Key ` -Description 'ScopeId for which reservations are set' IPAddress = New-xDscResourceProperty -Name IPAddress -Type String -Attribute Required ` ...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Samples/SampleConfiguration.ps1
SampleConfiguration.ps1
configuration Sample_xDhcpsServerScope_NewScope { Import-DscResource -module xDHCpServer WindowsFeature DHCP { Name = 'DHCP' Ensure = 'Present' } xDhcpServerScope Scope { Ensure = 'Present' IPStartRange = '192.168.1.1' IPEndRang...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Tests/Unit/MSFT_xDhcpServerAuthorization.Tests.ps1
MSFT_xDhcpServerAuthorization.Tests.ps1
$Global:DSCModuleName = 'xDhcpServer' $Global:DSCResourceName = 'MSFT_xDhcpServerAuthorization' #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCRes...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Tests/Unit/MSFT_xDhcpServerScope.Tests.ps1
MSFT_xDhcpServerScope.Tests.ps1
$Global:DSCModuleName = 'xDhcpServer' $Global:DSCResourceName = 'MSFT_xDhcpServerScope' #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ( (-not (Test-Path -Path (Join-Path -Path $moduleRoot -ChildPath 'DSCResource.Te...
PowerShellCorpus/PowerShellGallery/xDhcpServer/1.5.0.0/Tests/Unit/MSFT_xDhcpServerOption.tests.ps1
MSFT_xDhcpServerOption.tests.ps1
$Global:DSCModuleName = 'xDhcpServer' # Example xNetworking $Global:DSCResourceName = 'MSFT_xDhcpServerOption' # Example MSFT_xFirewall #region HEADER [String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $Script:MyInvocation.MyCommand.Path)) if ( (-not (Test-Path -Path (Join-P...
PowerShellCorpus/PowerShellGallery/DockerDsc/0.0.0.1/Examples/Example-DockerService.ps1
Example-DockerService.ps1
configuration docker { param ( [ValidateNotNullOrEmpty()] [String] $Path = 'C:\Program Files\Docker' ) Import-DscResource -ModuleName DockerDsc Import-DscResource -ModuleName xPSDesiredStateConfiguration node localhost { WindowsFeature containers { ...
PowerShellCorpus/PowerShellGallery/cSecurityOptions/3.1.2/DSCResources/Tests/Unit/UserRightsAssignment.Tests.ps1
UserRightsAssignment.Tests.ps1
$DSCResourceName = 'UserRightsAssignment' $DSCModuleName = 'cSecurityOptions' $Splat = @{ Path = $PSScriptRoot ChildPath = "..\..\DSCResources\$DSCResourceName\$DSCResourceName.psm1" Resolve = $true ErrorAction = 'Stop' } $DSCResourceModuleFile = Get-Item -Path (Join-Path @Splat) $modul...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Add-GacAssembly.ps1
Add-GacAssembly.ps1
<# .SYNOPSIS Adds the assembly to the GAC .DESCRIPTION Adds the assembly to the GAC. An assembly is only added to the GAC if the assembly is not already added to the GAC or if the file version is higher than the assembly already in the GAC. Can only be called from an elevated prompt. It must be a ...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Get-GacAssemblyInstallReference.ps1
Get-GacAssemblyInstallReference.ps1
<# .SYNOPSIS Gets the InstallReference of assemblies in the GAC .DESCRIPTION Gets the InstallRefernence of assemblies in the GAC. InstallRefernence shows if an assembly is referenced by an installer. .PARAMETER AssemblyName Specifies the assembly name. Must be fully qualified. See Test-AssemblyNameF...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Remove-GacAssembly.ps1
Remove-GacAssembly.ps1
<# .SYNOPSIS Removes the assembly from the GAC .DESCRIPTION Removes the assembly from the GAC. Can only be called from an elevated prompt. .PARAMETER AssemblyName Specifies the assembly name. Must be fully qualified. See Test-AssemblyNameFullyQualified. .PARAMETER InstallReference Specifies the Ins...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/New-GacAssemblyInstallReference.ps1
New-GacAssemblyInstallReference.ps1
<# .SYNOPSIS Creates a new install reference .DESCRIPTION Creates a new install reference to be used with Add-GacAssembly or Remove-GacAssembly .PARAMETER Type Specifies the type of the install reference to be created .PARAMETER Identifier Specifies the identifier of the install reference to be ...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Test-AssemblyNameFullyQualified.ps1
Test-AssemblyNameFullyQualified.ps1
<# .SYNOPSIS Determines whether the assembly name is fully qualified .DESCRIPTION Determines whether the assembly name is fully qualified. An assembly name is fully qualified if it contains all the following parts: * Name * Version * Culture * PublicKeyToken * ProcessorArchitecture Note t...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Get-GacAssemblyFile.ps1
Get-GacAssemblyFile.ps1
<# .SYNOPSIS Gets the FileInfo of assemblies in the GAC .DESCRIPTION Gets the FileInfo of assemblies in the GAC. FileInfo can be used as input for Copy-Item to extract an assembly from the GAC or to get the VersionInfo from the assembly. .PARAMETER AssemblyName Specifies the assembly name. Must be ...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Test-GacAssemblyInstallReferenceCanBeUsed.ps1
Test-GacAssemblyInstallReferenceCanBeUsed.ps1
<# .SYNOPSIS Determines whether the install reference can be used .DESCRIPTION Determines whether the install reference can be used with Add-GacAssembly and Remove-GacAssembly. Only types Installer, FilePath en Opaque can be used. WindowsInstaller and OsInstall not. .PARAMETER InstallReference S...
PowerShellCorpus/PowerShellGallery/Gac/1.0.1/Get-GacAssembly.ps1
Get-GacAssembly.ps1
<# .SYNOPSIS Gets the assemblies in the GAC .DESCRIPTION Gets the assemblies in the GAC. Assemblies can be filterd by Name, Version, Culture, PublicKeyToken or ProcessArchitecture. .PARAMETER Name Filter on the Name part. Supports wildcards. .PARAMETER Version Filter on the Version part. Support...
PowerShellCorpus/PowerShellGallery/LINQ/4.0/Add-SourceFiles.ps1
Add-SourceFiles.ps1
$ErrorActionPreference = 'Stop' function Add-SourceFile([String[]]$Path) { $CompilationUnit = New-Object System.Text.StringBuilder $AddTypeArgs = @{} if ($PSVersionTable.PSVersion.Major -ge 3) { $AddTypeArgs.Language = 'CSharp' $AddTypeArgs.ReferencedAssemblies = @('System.Core...
PowerShellCorpus/PowerShellGallery/xComputerManagement/1.10.0.0/Examples/Sample_xVirtualMemory.ps1
Sample_xVirtualMemory.ps1
<# .SYNOPSIS Example to set the paging file .DESCRIPTION Example script that sets the paging file to reside on drive C with the custom size 2048MB #> configuration Sample_xVirtualMemory { param ( [Parameter()] [String[]] $NodeName = 'localhost' ) Import-DS...
PowerShellCorpus/PowerShellGallery/xComputerManagement/1.10.0.0/Examples/Sample_xScheduledTask.ps1
Sample_xScheduledTask.ps1
configuration Sample_xScheduledTask { param ( [string[]]$NodeName = 'localhost' ) Import-DSCResource -ModuleName xComputerManagement Node $NodeName { xScheduledTask MaintenanceScriptExample { TaskName = "Custom maintenance tasks" Action...
PowerShellCorpus/PowerShellGallery/xComputerManagement/1.10.0.0/Examples/Sample_xPowerPlan.ps1
Sample_xPowerPlan.ps1
<# .SYNOPSIS Example to set a power plan. .DESCRIPTION This examples sets the active power plan to the 'High performance' plan. #> Configuration Sample_xPowerPlan { param ( [Parameter()] [String[]] $NodeName = 'localhost' ) Import-DSCRe...