full_path stringlengths 31 232 | filename stringlengths 4 167 | content stringlengths 0 48.3M |
|---|---|---|
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Mock.Tests.ps1 | Mock.Tests.ps1 | Set-StrictMode -Version Latest
function FunctionUnderTest
{
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[string]
$param1
)
return "I am a real world test"
}
function FunctionUnderTestWithoutParams([string]$param1) {
return "I am a real world test with no params... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Coverage.Tests.ps1 | Coverage.Tests.ps1 | if ($PSVersionTable.PSVersion.Major -le 2) { return }
InModuleScope Pester {
Describe 'Code Coverage Analysis' {
$root = (Get-PSDrive TestDrive).Root
$null = New-Item -Path $root\TestScript.ps1 -ItemType File -ErrorAction SilentlyContinue
Set-Content -Path $root\TestScript.ps1 -Value @'
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/It.ps1 | It.ps1 | function It {
<#
.SYNOPSIS
Validates the results of a test inside of a Describe block.
.DESCRIPTION
The It command is intended to be used inside of a Describe or Context Block.
If you are familiar with the AAA pattern (Arrange-Act-Assert), the body of
the It block is the appropriate location for an assert. The convent... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/In.ps1 | In.ps1 | function In {
<#
.SYNOPSIS
A convenience function that executes a script from a specified path.
.DESCRIPTION
Before the script block passed to the execute parameter is invoked,
the current location is set to the path specified. Once the script
block has been executed, the location will be reset to the location
the scr... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/SetupTeardown.Tests.ps1 | SetupTeardown.Tests.ps1 | Describe 'Describe-Scoped Test Case setup' {
BeforeEach {
$testVariable = 'From BeforeEach'
}
$testVariable = 'Set in Describe'
It 'Assigns the correct value in first test' {
$testVariable | Should Be 'From BeforeEach'
$testVariable = 'Set in It'
}
It 'Assigns the corr... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/GlobalMock-A.Tests.ps1 | GlobalMock-A.Tests.ps1 | # This script exists to create and mock a global function, then exit. The actual behavior
# that we need to test is covered in GlobalMock-B.Tests.ps1, where we make sure that the
# global function was properly restored in its scope.
$functionName = '01c1a57716fe4005ac1a7bf216f38ad0'
if (Test-Path Function:\$function... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/InModuleScope.ps1 | InModuleScope.ps1 | function InModuleScope
{
<#
.SYNOPSIS
Allows you to execute parts of a test script within the
scope of a PowerShell script module.
.DESCRIPTION
By injecting some test code into the scope of a PowerShell
script module, you can use non-exported functions, aliases
and variables inside that module, to perfor... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Mock.ps1 | Mock.ps1 | function Mock {
<#
.SYNOPSIS
Mocks the behavior of an existing command with an alternate
implementation.
.DESCRIPTION
This creates new behavior for any existing command within the scope of a
Describe or Context block. The function allows you to specify a script block
that will become the command's new behavior.
Opti... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Describe.ps1 | Describe.ps1 | function Describe {
<#
.SYNOPSIS
Creates a logical group of tests. All Mocks and TestDrive contents
defined within a Describe block are scoped to that Describe; they
will no longer be present when the Describe block exits. A Describe
block may contain any number of Context and It blocks.
.PARAMETER Name
The name of ... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Match.ps1 | Match.ps1 |
function PesterMatch($value, $expectedMatch) {
return ($value -match $expectedMatch)
}
function PesterMatchFailureMessage($value, $expectedMatch) {
return "Expected: {$value} to match the expression {$expectedMatch}"
}
function NotPesterMatchFailureMessage($value, $expectedMatch) {
return "Expected: ${va... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/MatchExactly.Tests.ps1 | MatchExactly.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "MatchExactly" {
It "returns true for things that match exactly" {
PesterMatchExactly "foobar" "ob" | Should Be $true
}
It "returns false for things that do not match exactly" {
PesterMatchExactly "fooba... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Set-TestInconclusive.ps1 | Set-TestInconclusive.ps1 | function New-InconclusiveErrorRecord ([string] $Message, [string] $File, [string] $Line, [string] $LineText) {
$exception = New-Object Exception $Message
$errorID = 'PesterTestInconclusive'
$errorCategory = [Management.Automation.ErrorCategory]::InvalidResult
# we use ErrorRecord.TargetObject to pass st... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/PesterThrow.Tests.ps1 | PesterThrow.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterThrow" {
It "returns true if the statement throws an exception" {
Test-PositiveAssertion (PesterThrow { throw })
}
It "returns false if the statement does not throw an exception" {
Test-NegativeAs... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeNullOrEmpty.ps1 | BeNullOrEmpty.ps1 |
function PesterBeNullOrEmpty($value) {
if ($null -eq $value) {
return $true
}
if ([String] -eq $value.GetType()) {
return [String]::IsNullOrEmpty($value)
}
if ($null -ne $value.PSObject.Properties['Count'] -and
$null -ne $value.Count) {
return $value.Count -lt 1
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Should.Tests.ps1 | Should.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "Parse-ShouldArgs" {
It "sanitizes assertions functions" {
$parsedArgs = Parse-ShouldArgs TestFunction
$parsedArgs.AssertionMethod | Should Be PesterTestFunction
}
It "works with strict mode when using '... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Exist.ps1 | Exist.ps1 |
function PesterExist($value) {
& $SafeCommands['Test-Path'] $value
}
function PesterExistFailureMessage($value) {
return "Expected: {$value} to exist"
}
function NotPesterExistFailureMessage($value) {
return "Expected: ${value} to not exist, but it was found"
}
|
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/PesterThrow.ps1 | PesterThrow.ps1 |
$ActualExceptionMessage = ""
$ActualExceptionWasThrown = $false
# because this is a script block, the user will have to
# wrap the code they want to assert on in { }
function PesterThrow([scriptblock] $script, $expectedErrorMessage) {
$Script:ActualExceptionMessage = ""
$Script:ActualExceptionWasThrown = $fal... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeLessThan.Tests.ps1 | BeLessThan.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeLessThan" {
It "passes if value Less than expected" {
Test-PositiveAssertion (PesterBeLessThan 1 2)
1 | Should BeLessThan 2
}
It "fails if values equal" {
Test-NegativeAssertion (Pest... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeGreaterThan.ps1 | BeGreaterThan.ps1 | function PesterBeGreaterThan($value, $expected)
{
return [bool]($value -gt $expected)
}
function PesterBeGreaterThanFailureMessage($value,$expected)
{
return "Expected {$value} to be greater than {$expected}"
}
function NotPesterBeGreaterThanFailureMessage($value,$expected)
{
return "Expected {$value} to ... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeNullOrEmpty.Tests.ps1 | BeNullOrEmpty.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeNullOrEmpty" {
It "should return true if null" {
Test-PositiveAssertion (PesterBeNullOrEmpty $null)
}
It "should return true if empty string" {
Test-PositiveAssertion (PesterBeNullOrEmpty "")
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/MatchExactly.ps1 | MatchExactly.ps1 |
function PesterMatchExactly($value, $expectedMatch) {
return ($value -cmatch $expectedMatch)
}
function PesterMatchExactlyFailureMessage($value, $expectedMatch) {
return "Expected: {$value} to exactly match the expression {$expectedMatch}"
}
function NotPesterMatchExactlyFailureMessage($value, $expectedMatch... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Match.Tests.ps1 | Match.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "Match" {
It "returns true for things that match" {
PesterMatch "foobar" "ob" | Should Be $true
}
It "returns false for things that do not match" {
PesterMatch "foobar" "slime" | Should Be $false
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeGreaterThan.Tests.ps1 | BeGreaterThan.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeGreaterThan" {
It "passes if value greater than expected" {
Test-PositiveAssertion (PesterBeGreaterThan 2 1)
2 | Should BeGreaterThan 1
}
It "fails if values equal" {
Test-NegativeAss... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Be.ps1 | Be.ps1 | #Be
function PesterBe($value, $expected) {
return ($expected -eq $value)
}
function PesterBeFailureMessage($value, $expected) {
if (-not (($expected -is [string]) -and ($value -is [string])))
{
return "Expected: {$expected}`nBut was: {$value}"
}
<#joining the output strings to a single str... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Contain.Tests.ps1 | Contain.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterContain" {
Context "when testing file contents" {
Setup -File "test.txt" "this is line 1`nrush is awesome`nAnd this is Unicode: ☺"
It "returns true if the file contains the specified content" {
Te... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Test-Assertion.ps1 | Test-Assertion.ps1 |
function Test-PositiveAssertion($result) {
if (-not $result) {
throw "Expecting expression to pass, but it failed"
}
}
function Test-NegativeAssertion($result) {
if ($result) {
throw "Expecting expression to pass, but it failed"
}
}
|
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeOfType.Tests.ps1 | BeOfType.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBeOfType" {
It "passes if value is of the expected type" {
Test-PositiveAssertion (PesterBeOfType 1 ([int]))
Test-PositiveAssertion (PesterBeOfType 1 "Int")
1 | Should BeOfType Int
2.0 | Sh... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Contain.ps1 | Contain.ps1 |
function PesterContain($file, $contentExpecation) {
return ((& $SafeCommands['Get-Content'] -Encoding UTF8 $file) -match $contentExpecation)
}
function PesterContainFailureMessage($file, $contentExpecation) {
return "Expected: file ${file} to contain {$contentExpecation}"
}
function NotPesterContainFailureMe... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Should.ps1 | Should.ps1 | function Parse-ShouldArgs([array] $shouldArgs) {
if ($null -eq $shouldArgs) { $shouldArgs = @() }
$parsedArgs = @{
PositiveAssertion = $true
ExpectedValue = $null
}
$assertionMethodIndex = 0
$expectedValueIndex = 1
if ($shouldArgs.Count -gt 0 -and $shouldArgs[0].ToLower() -e... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeOfType.ps1 | BeOfType.ps1 |
function PesterBeOfType($value, $expectedType) {
trap [System.Management.Automation.PSInvalidCastException] { return $false }
if($expectedType -is [string] -and !($expectedType -as [Type])) {
$expectedType = $expectedType -replace '^\[(.*)\]$','$1'
}
return [bool]($value -is $expectedType)
}
f... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Exist.Tests.ps1 | Exist.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterExist" {
It "returns true for paths that exist" {
Test-PositiveAssertion (PesterExist $TestDrive)
}
It "returns false for paths do not exist" {
Test-NegativeAssertion (PesterExist "$TestDrive\none... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/BeLessThan.ps1 | BeLessThan.ps1 | function PesterBeLessThan($value, $expected)
{
return [bool]($value -lt $expected)
}
function PesterBeLessThanFailureMessage($value,$expected)
{
return "Expected {$value} to be less than {$expected}"
}
function NotPesterBeLessThanFailureMessage($value,$expected)
{
return "Expected {$value} to be greater t... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/Be.Tests.ps1 | Be.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterBe" {
It "returns true if the 2 arguments are equal" {
Test-PositiveAssertion (PesterBe 1 1)
}
It "returns true if the 2 arguments are equal and have different case" {
Test-PositiveAssertion (Peste... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/ContainExactly.Tests.ps1 | ContainExactly.Tests.ps1 | Set-StrictMode -Version Latest
InModuleScope Pester {
Describe "PesterContainExactly" {
Context "when testing file contents" {
Setup -File "test.txt" "this is line 1`nPester is awesome`nAnd this is Unicode: ☺"
It "returns true if the file contains the specified content exactly" {
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/lib/Pester/3.3.14/Functions/Assertions/ContainExactly.ps1 | ContainExactly.ps1 | function PesterContainExactly($file, $contentExpecation) {
return ((& $SafeCommands['Get-Content'] -Encoding UTF8 $file) -cmatch $contentExpecation)
}
function PesterContainExactlyFailureMessage($file, $contentExpecation) {
return "Expected: file ${file} to contain exactly {$contentExpecation}"
}
function Not... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/Invoke-PSRemotely.ps1 | Invoke-PSRemotely.ps1 | Function Invoke-PSRemotely {
<#
.SYNOPSIS
Invoke PSRemotely
.DESCRIPTION
Invoke PSRemotely
Searches for .PSRemotely.ps1 files in the current and nested paths, and invokes the remote ops validation.
By default PSRemotely would run all the
.PARAMETER Script
Path to ... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/Clear-RemoteSession.ps1 | Clear-RemoteSession.ps1 | function Clear-RemoteSession
{
<#
.SYNOPSIS
Function which clears out all the PSSessions in use by PSRemotely.
It will also update the global variable PSRemotely's NodeMap and sessionHashTable.
.NOTES
Read the documentation hosted on GitHub for the project for using the DSL.
.LINK
PSRemotely
Node
... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/Get-RemoteSession.ps1 | Get-RemoteSession.ps1 | function Get-RemoteSession
{
<#
.SYNOPSIS
Function which lists out all the PSSessions in use by PSRemotely.
The session name follow the naming convention of -> PSRemotely-<NodeName>
.NOTES
Read the documentation hosted on GitHub for the project for using the DSL.
.LINK
PSRemotely
Node
Invoke-PSRemotel... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/Enter-PSRemotely.ps1 | Enter-PSRemotely.ps1 | Function Enter-PSRemotely {
[CmdletBinding()]
param (
# Specify this switch to get the PSSession object
[Switch]$PassThru
)
DynamicParam {
# Add a dynamic parameter 'NodeName' which discovers the PSRemotely nodes by looking at
# the $PSRemotely global variable
if... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/PSRemotely.ps1 | PSRemotely.ps1 | function PSRemotely
{
<#
.SYNOPSIS
Provides a Keyword to wrap around the existing Ops validation tests.
.PARAMETER Body
Scriptblock enclosing the Node block to target the remote ops validation at.
.PARAMETER ConfigurationData
Provide DSC style ConfigurationData for environment details to PSRemotely.
.PARAMET... |
PowerShellCorpus/PowerShellGallery/PSRemotely/1.0.4/public/Node.ps1 | Node.ps1 | Function Node {
<#
.SYNOPSIS
Function implementing the 'Node' keyword logic.
The Node keyword targets the remote nodes by bootstrapping the nodes and getting them ready for PSRemotely.
.PARAMETER Name
DNS name of the remote name to target for the Remote ops validation.
.PARAMETER testBlock
Scriptblock housi... |
PowerShellCorpus/PowerShellGallery/PoshUSNJournal/0.4.3.0/Scripts/New-UsnJournal.ps1 | New-UsnJournal.ps1 | Function New-UsnJournal {
[cmdletbinding(
SupportsShouldProcess = $True
)]
Param (
[parameter()]
[ValidateScript({
If ($_ -notmatch '^\w:$') {
Throw "$($_) must match this format: C:"
} Else {$True}
})]
[string]$Drive... |
PowerShellCorpus/PowerShellGallery/PoshUSNJournal/0.4.3.0/Scripts/Remove-UsnJournal.ps1 | Remove-UsnJournal.ps1 | Function Remove-UsnJournal {
[cmdletbinding(
SupportsShouldProcess = $True
)]
Param (
[parameter()]
[ValidateScript({
If ($_ -notmatch '^\w:$') {
Throw "$($_) must match this format: C:"
} Else {$True}
})]
[string]$Dr... |
PowerShellCorpus/PowerShellGallery/PoshUSNJournal/0.4.3.0/Scripts/Get-UsnJournal.ps1 | Get-UsnJournal.ps1 | Function Get-UsnJournal {
[OutputType('System.Journal.UsnJournal')]
Param ($DriveLetter = 'C:')
$JournalData = New-Object USN_JOURNAL_DATA
[long]$dwBytes=0
$VolumeHandle = OpenUSNJournal -DriveLetter $DriveLetter
If ($VolumeHandle -AND $VolumeHandle -ne -1) {
$return = [PoshChJour... |
PowerShellCorpus/PowerShellGallery/PoshUSNJournal/0.4.3.0/Scripts/Get-UsnJournalEntry.ps1 | Get-UsnJournalEntry.ps1 | Function Get-UsnJournalEntry {
<#
.SYNOPSIS
Views the entries of the Usn Journal. Also allows the use of -Wait to
watch incoming entries.
.DESCRIPTION
Views the entries of the Usn Journal. Includes full file path and also allows
the use of -... |
PowerShellCorpus/PowerShellGallery/PromptEd/1.1/BuiltInPrompts.ps1 | BuiltInPrompts.ps1 | # Define some colors for use in prompts
Add-PromptColor Path $Host.UI.RawUI.ForegroundColor
Add-PromptColor Preamble Magenta
Add-PromptColor Time Blue
Add-PromptColor Brackets Green
# Helper functions common to various prompt elements
function script:Get-CurrentLocation
{
"$($executionContext.SessionState... |
PowerShellCorpus/PowerShellGallery/PromptEd/1.1/PromptTasks.ps1 | PromptTasks.ps1 | $script:promptTasks = [ordered]@{}
function script:Invoke-PromptTasks
{
param(
[Parameter(Position=0, Mandatory=$true)]
[int]$realLASTEXITCODE
)
foreach($task in $script:promptTasks.Values)
{
$task.Invoke()
$LASTEXITCODE = $realLASTEXITCODE
}
}
... |
PowerShellCorpus/PowerShellGallery/PromptEd/1.1/PromptEdTabExpansion.ps1 | PromptEdTabExpansion.ps1 | function BuiltInPromptCompletion
{
param($commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters)
Get-BuiltInPromptNames | Where-Object { $_ -match "^$wordToComplete" } | ForEach-Object{ New-CompletionResult $_ }
}
if(Get-Modu... |
PowerShellCorpus/PowerShellGallery/PromptEd/1.1/PromptWriting.ps1 | PromptWriting.ps1 | param(
[Parameter(Position=0, Mandatory=$true)]
[PSModuleInfo]$PromptEdModule
)
$script:oldPrompt = $function:prompt
$script:promptElements = @()
$script:promptElements += $script:oldPrompt
function script:Write-Prompt
{
for($i = 0; $i -lt $script:promptElements.Count; $i++)
{
$sc... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Assert-HADC.ps1 | Assert-HADC.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingComputerNameHardcoded', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
# A configuration to Create High Availability Domain Controller
$secpasswd = ConvertTo-Secure... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Assert-ParentChildDomains.ps1 | Assert-ParentChildDomains.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingComputerNameHardcoded', '')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$secpasswd = ConvertTo-SecureString "Adrumble@6" -AsPlainText -Force
$domainCred = New-Object... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Misc/New-ADDomainTrust.ps1 | New-ADDomainTrust.ps1 | $Properties = @{
SourceDomain = New-xDscResourceProperty -Name SourceDomainName -Type String -Attribute Key `
-Description 'Name of the AD domain that is requesting the trust'
TargetDomain = New-xDscResourceProperty -Nam... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/DSCResources/MSFT_xADRecycleBin/Examples/xActiveDirectory_xADRecycleBin.ps1 | xActiveDirectory_xADRecycleBin.ps1 | Configuration Example_xADRecycleBin
{
Param(
[parameter(Mandatory = $true)]
[System.String]
$ForestFQDN,
[parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$EACredential
)
Import-DscResource -Module xActiveDirectory
Node $AllNodes.NodeName
{... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/DSCResources/MSFT_xADRecycleBin/ResourceDesignerScripts/GeneratexADRecycleBinSchema.ps1 | GeneratexADRecycleBinSchema.ps1 | New-xDscResource -Name MSFT_xADRecycleBin -FriendlyName xADRecycleBin -ModuleName xActiveDirectory -Path . -Force -Property @(
New-xDscResourceProperty -Name ForestFQDN -Type String -Attribute Key
New-xDscResourceProperty -Name EnterpriseAdministratorCredential -Type PSCredential -Attribute Required
New-... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/DSCResources/MSFT_xADCommon/MSFT_xADCommon.ps1 | MSFT_xADCommon.ps1 | data localizedString
{
# culture="en-US"
ConvertFrom-StringData @'
RoleNotFoundError = Please ensure that the PowerShell module for role '{0}' is installed
MembersAndIncludeExcludeError = The '{0}' and '{1}' and/or '{2}' parameters conflict. The '{0}' parameter should not be u... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADDomain.Tests.ps1 | MSFT_xADDomain.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADDomain' # Example MSFT_xFirewall
#region HEADER
[String] $moduleRoot = Split-Path ... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xWaitForADDomain.Tests.ps1 | MSFT_xWaitForADDomain.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory'
$Global:DSCResourceName = 'MSFT_xWaitForADDomain'
#region HEADER
[String] $moduleRoot = Split-Path -Parent (Split-Path -Parent (Split-Path ... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADCommon.Tests.ps1 | MSFT_xADCommon.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADCommon' # Example MSFT_xFirewall
#region HEADER
[String] $moduleRoot = Split-Path ... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADComputer.Tests.ps1 | MSFT_xADComputer.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADComputer' # Example MSFT_xFirewall
#region HEADER
# Unit Test Template Version: 1.... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADDomainController.Tests.ps1 | MSFT_xADDomainController.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Script:DSCModuleName = 'xActiveDirectory'
$Script:DSCResourceName = 'MSFT_xADDomainController'
#region HEADER
[String] $script:moduleRoot = Split-Path -Parent (Split-Path -Parent $P... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADOrganizationalUnit.Tests.ps1 | MSFT_xADOrganizationalUnit.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADOrganizationalUnit' # Example MSFT_xFirewall
#region HEADER
[String] $moduleRoot =... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADGroup.Tests.ps1 | MSFT_xADGroup.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADGroup' # Example MSFT_xFirewall
#region HEADER
[String] $moduleRoot = Split-Path -... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADUser.Tests.ps1 | MSFT_xADUser.Tests.ps1 | $Global:DSCModuleName = 'xActiveDirectory'
$Global:DSCResourceName = 'MSFT_xADUser'
#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.Tests'... |
PowerShellCorpus/PowerShellGallery/xActiveDirectory/2.16.0.0/Tests/Unit/MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 | MSFT_xADDomainDefaultPasswordPolicy.Tests.ps1 | [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '')]
param()
$Global:DSCModuleName = 'xActiveDirectory' # Example xNetworking
$Global:DSCResourceName = 'MSFT_xADDomainDefaultPasswordPolicy' # Example MSFT_xFirewall
#region HEADER
[String] $mod... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Private/_CheckValidLanguage.ps1 | _CheckValidLanguage.ps1 | function _CheckValidLanguage{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)][String] $language
)
begin{
Write-Debug "Starting _CheckValidLanguage with $language"
}
process{
$languageMatrix = @(
"ar",
"bg",
"bs",
... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Private/_VerifyResolutionMatrix.ps1 | _VerifyResolutionMatrix.ps1 | function _VerifyResolutionMatrix{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)][String[]] $resolution
)
begin{
Write-Debug "Starting _VerifyResolutionMatrix with $resolution"
}
process{
$resolution | ForEach-Object{
if(-not ($_ -match '^[... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Private/_InvokeImaggaApi.ps1 | _InvokeImaggaApi.ps1 | function _InvokeImaggaApi{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)][pscredential] $credential,
[parameter(Mandatory=$true)][String] $parameters,
[parameter(Mandatory=$true)][String] $function
)
begin{
Write-Debug "Starting _InvokeImaggaApi with $par... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Private/_CheckValidImage.ps1 | _CheckValidImage.ps1 | function _CheckValidImage{
[CmdletBinding()]
param(
[parameter(Mandatory=$true)][String] $url
)
begin{
Write-Debug "Starting _CheckValidImage with $url"
}
process{
try{
$image = invoke-webrequest $url -DisableKeepAlive -UseBasicParsing
}... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Public/get-imagecolors.ps1 | get-imagecolors.ps1 | #requires -version 4
Function Get-ImageColor{
<#
.SYNOPSIS
Analyse and extract the predominant colors from one or several images.
.DESCRIPTION
The Get-ImageColor function is part of Imagga module. It analyses and extract the predominant colors from one or several images.
.PARAMETER url
The url of the imag... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Public/get-croppedimage.ps1 | get-croppedimage.ps1 | #requires -version 4
Function Get-CroppedImage{
<#
.SYNOPSIS
Get cropped images from imagga
.DESCRIPTION
The Get-CroppedImage function is part of Imagga module. It retrieves cropped version of the image passed as parameter. Images will match dimension passed in the resolution parameter.
.PARAMETER url
The... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Public/get-imagetag.ps1 | get-imagetag.ps1 | #requires -version 4
Function Get-ImageTag{
<#
.SYNOPSIS
Get recommended tags from imagga
.DESCRIPTION
The Get-ImageTag function is part of Imagga module. It retrieves the suggested tags to associate to the image passed as parameter.
.PARAMETER url
The url of the image to be tagged. It has to be accessibl... |
PowerShellCorpus/PowerShellGallery/imagga/0.1.1/Public/new-imaggaconnection.ps1 | new-imaggaconnection.ps1 | #requires -version 4
Function New-ImaggaConnection{
<#
.SYNOPSIS
Create an imagga connection object
.DESCRIPTION
The new-imaggaconnection function is part of Imagga module. It gets the imagga apikey and secret and create a connection object (PSCredential) to be used to connect to imagga.
.PARAMETER apikey
... |
PowerShellCorpus/PowerShellGallery/MeasureTrace.Database/0.41.0/MakePsModuleDirFromBuildDir.ps1 | MakePsModuleDirFromBuildDir.ps1 | <#
Written and shared by Microsoft employee Matthew Reynolds in the spirit of "Small OSS libraries, tool, and sample code" OSS policy
MIT license https://github.com/MatthewMWR/MeasureTrace/blob/master/LICENSE
#>
param($Source = $psscriptroot, $InstallScope = 'CurrentUser', $Filter = '*.psd1')
foreach($modul... |
PowerShellCorpus/PowerShellGallery/MeasureTrace.Database/0.41.0/MeasureTrace.Database.tests.ps1 | MeasureTrace.Database.tests.ps1 | <#
Written and shared by Microsoft employee Matthew Reynolds in the spirit of "Small OSS libraries, tool, and sample code" OSS policy
MIT license https://github.com/MatthewMWR/MeasureTrace/blob/master/LICENSE
#>
Describe "MeasureTrace.Database core API" {
$sqlServerConnectionString = "server=(localdb)\MsSqlL... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/ConvertFrom-UnixTime.ps1 | ConvertFrom-UnixTime.ps1 | #From http://powershell.com/cs/blogs/tips/archive/2012/03/09/converting-unix-time.aspx - Thanks!
function ConvertFrom-UnixTime {
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true)]
[Int32]
$UnixTime
)
begin {
$startdate = Get-Date –Date '01/01/1970... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Parse-SlackGroup.ps1 | Parse-SlackGroup.ps1 | Function Parse-SlackGroup {
[cmdletbinding()]
param( $InputObject )
foreach($Group in $InputObject)
{
$TopicSet = $null
$PurposeSet = $null
if($Group.Purpose.last_set)
{
$PurposeSet = ConvertFrom-UnixTime $Group.Purpose.last_set
}
if($Group.to... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Color-ToNumber.ps1 | Color-ToNumber.ps1 | Function Color-ToNumber {
[cmdletbinding()]
param(
[object]$Color
)
if(-not $IsCoreCLR)
{
[System.Drawing.Color] $Color = $Color
'#{0:X2}{1:X2}{2:X2}' -f $Color.R,
$Color.G,
$Color.B
}
} |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Parse-SlackChannel.ps1 | Parse-SlackChannel.ps1 | # Parse channels
Function Parse-SlackChannel {
[cmdletbinding()]
param( $InputObject )
foreach($Channel in $InputObject)
{
$TopicSet = $null
$PurposeSet = $null
if($Channel.Purpose.last_set)
{
$PurposeSet = ConvertFrom-UnixTime $Channel.Purpose.last_set
... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Parse-SlackMessage.ps1 | Parse-SlackMessage.ps1 | # Parse output from search.messages
Function Parse-SlackMessage {
[cmdletbinding()]
param(
$InputObject,
[switch]$Match
)
function Extract-Previous {
param($Message)
if($Message.username -or $Message.Text)
{
"@{0}: {1}" -f $Message.Usernam... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Add-ObjectDetail.ps1 | Add-ObjectDetail.ps1 | function Add-ObjectDetail
{
<#
.SYNOPSIS
Decorate an object with
- A TypeName
- New properties
- Default parameters
.DESCRIPTION
Helper function to decorate an object with
- A TypeName
- New properties
- De... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Get-PropertyOrder.ps1 | Get-PropertyOrder.ps1 | #function to extract properties
Function Get-PropertyOrder {
<#
.SYNOPSIS
Gets property order for specified object
.DESCRIPTION
Gets property order for specified object
.PARAMETER InputObject
A single object to convert to an array of property value pairs.
.PARAMETER Member... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Private/Parse-SlackUser.ps1 | Parse-SlackUser.ps1 | # Parse users
Function Parse-SlackUser {
[cmdletbinding()]
param( $InputObject )
foreach($User in $InputObject)
{
[pscustomobject]@{
PSTypeName = 'PSSlack.User'
ID = $User.id
Name = $User.name
RealName = $User.Profile.Real_Name
FirstN... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-SlackChannel.ps1 | Get-SlackChannel.ps1 | function Get-SlackChannel {
<#
.SYNOPSIS
Get information about Slack channels
.DESCRIPTION
Get information about Slack channels
.PARAMETER Token
Specify a token for authorization.
See 'Authentication' section here for more information: https://api.slack.com/web
... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/New-SlackField.ps1 | New-SlackField.ps1 | function New-SlackField
{
<#
.SYNOPSIS
Creates an array of Slack message attachment fields from an arbitrary PowerShell object
.DESCRIPTION
Creates an array of Slack message attachment fields from an arbitrary PowerShell object
By default, retrieves all properties. You can use para... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-PSSlackConfig.ps1 | Get-PSSlackConfig.ps1 | Function Get-PSSlackConfig {
<#
.SYNOPSIS
Get PSSlack module configuration.
.DESCRIPTION
Get PSSlack module configuration
.PARAMETER Source
Get the config data from either...
PSSlack: the live module variable used for command defaults
... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/New-SlackMessageAttachment.ps1 | New-SlackMessageAttachment.ps1 | #Borrowed from https://github.com/jgigler/Powershell.Slack - thanks @jgigler et al!
function New-SlackMessageAttachment
{
<#
.SYNOPSIS
Creates a rich notification (Attachment) to use in a Slack message.
.DESCRIPTION
Creates a rich notification (Attachment) to use in a Slack message.... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Find-SlackMessage.ps1 | Find-SlackMessage.ps1 | function Find-SlackMessage {
<#
.SYNOPSIS
Search a Slack team for a message
.DESCRIPTION
Search a Slack team for a message
Output will include details on the matching message, along with 'previous' and 'next' for context.
.PARAMETER Query
Search query. May c... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Send-SlackAPI.ps1 | Send-SlackAPI.ps1 | function Send-SlackApi
{
<#
.SYNOPSIS
Send a message to the Slack API endpoint
.DESCRIPTION
Send a message to the Slack API endpoint
This function is used by other PSSlack functions.
It's a simple wrapper you could use for calls to the Slack API
.PARAMETER ... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-SlackGroupHistory.ps1 | Get-SlackGroupHistory.ps1 | function Get-SlackGroupHistory {
<#
.SYNOPSIS
Get history from a Slack group
.DESCRIPTION
Get history from a Slack group
.PARAMETER Token
Specify a token for authorization.
See 'Authentication' section here for more information: https://api.slack.com/web
Test t... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Send-SlackFile.ps1 | Send-SlackFile.ps1 | function Send-SlackFile {
<#
.SYNOPSIS
Send a Slack file
.DESCRIPTION
Send a Slack file
.PARAMETER Token
Token to use for the Slack API
Default value is the value set by Set-PSSlackConfig
.PARAMETER Content
Content of the file to send. Text is editable af... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-SlackHistory.ps1 | Get-SlackHistory.ps1 | function Get-SlackHistory {
<#
.SYNOPSIS
Get history from a Slack channel
.DESCRIPTION
Get history from a Slack channel
.PARAMETER Token
Specify a token for authorization.
See 'Authentication' section here for more information: https://api.slack.com/web
Test to... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-SlackUser.ps1 | Get-SlackUser.ps1 | function Get-SlackUser {
<#
.SYNOPSIS
Get info on a Slack user
.DESCRIPTION
Get info on a Slack user
.PARAMETER Token
Token to use for the Slack API
Default value is the value set by Set-PSSlackConfig
.PARAMETER Presence
Whether to include presence informa... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Send-SlackMessage.ps1 | Send-SlackMessage.ps1 | function Send-SlackMessage {
<#
.SYNOPSIS
Send a Slack message
.DESCRIPTION
Send a Slack message
You can use the parameters here to build the message, or
provide a SlackMessage created with New-SlackMessage
.PARAMETER Token
Token to use for the Slac... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Get-SlackGroup.ps1 | Get-SlackGroup.ps1 | function Get-SlackGroup {
<#
.SYNOPSIS
Get information about Slack groups
.DESCRIPTION
Get information about Slack groups
.PARAMETER Token
Specify a token for authorization.
See 'Authentication' section here for more information: https://api.slack.com/web
Test ... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/New-SlackMessage.ps1 | New-SlackMessage.ps1 | function New-SlackMessage
{
<#
.SYNOPSIS
Construct a new Slack message
.DESCRIPTION
Construct a new Slack message
Note that this does not send a message
It produces a message to send with Send-SlackMessage
.PARAMETER Channel
Channel, private group,... |
PowerShellCorpus/PowerShellGallery/PSSlack/0.0.17/Public/Set-PSSlackConfig.ps1 | Set-PSSlackConfig.ps1 | function Set-PSSlackConfig {
<#
.SYNOPSIS
Set PSSlack module configuration.
.DESCRIPTION
Set PSSlack module configuration, and $PSSlack module variable.
This data is used as the default Token and Uri for most commands.
If a command takes either a token or a uri, ... |
PowerShellCorpus/PowerShellGallery/PSTeachingTools/1.1.0/Start-TypedDemo.ps1 | Start-TypedDemo.ps1 | #Requires -version 5.0
Function Start-TypedDemo {
[cmdletBinding(DefaultParameterSetName="Random")]
Param(
[Parameter(Position=0,Mandatory=$True,HelpMessage="Enter the name of a text file with your demo commands")]
[ValidateScript({Test-Path $_})]
[string]$File,
[ValidateScript({$_ -gt 0})]
[Parameter(Param... |
PowerShellCorpus/PowerShellGallery/PSTeachingTools/1.1.0/Vegetables.ps1 | Vegetables.ps1 | #requires -version 5.0
#region object definitions
#enumerations for a few of the class properties
Enum Status {
Raw
Boiled
Steamed
Sauteed
Fried
Baked
Roasted
Grilled
}
Enum VegColor {
green
red
white
yellow
orange
purple
brown
}
... |
PowerShellCorpus/PowerShellGallery/PSTeachingTools/1.1.0/Tests/PSTeachingTools.tests.ps1 | PSTeachingTools.tests.ps1 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. $here\..\$sut
Describe PSTeachingTools {
It "does something useful" {
$true | Should Be $true
}
}
|
PowerShellCorpus/PowerShellGallery/PsBamboo/2.2.1.0/Examples/ProjectAndPlan.examples.ps1 | ProjectAndPlan.examples.ps1 | param(
[Parameter()]
[string]$Server = 'http://localhost:8085',
[Parameter(Mandatory=$true)]
[pscredential]$Credential
)
# Use local module for the examples
Remove-Module PsBamboo -ErrorAction SilentlyContinue
$localModule = Join-Path (Split-Path $PSScriptRoot -Parent) "PsBamboo.psm1"
Import-Module $l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.