forked from adbertram/Random-PowerShell-Work
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#requires -Module Pester | ||
|
||
function Start-PesterTest | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Module, | ||
|
||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[ValidateSet('Unit','Integration','Acceptance')] | ||
[string]$Type, | ||
|
||
[Parameter()] | ||
[string]$TestName, | ||
|
||
[Parameter()] | ||
[hashtable]$AdditionalParams | ||
) | ||
begin | ||
{ | ||
$ErrorActionPreference = 'Stop' | ||
} | ||
process | ||
{ | ||
try | ||
{ | ||
if (-not ($testScript = Find-TestScript -Module $Module -Type $Type)) { | ||
throw "Could not find $Type test script for the [$($Module)] module." | ||
} else { | ||
$invPestParams = @{ | ||
Path = $testScript.FullName | ||
} | ||
if ($PSBoundParameters.ContainsKey('InvokePesterParams')) | ||
{ | ||
$invPestParams += $AdditionalParams | ||
} | ||
if ($PSBoundParameters.ContainsKey('TestName')) | ||
{ | ||
$invPestParams.TestName = $TestName | ||
} | ||
Invoke-Pester @invPestParams | ||
|
||
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Invoke-Pester', [System.Management.Automation.CommandTypes]::Function) | ||
$scriptCmd = { & $wrappedCmd @invPestParams } | ||
$steppablePipeline = $scriptCmd.GetSteppablePipeline() | ||
$steppablePipeline.Begin($PSCmdlet) | ||
} | ||
} | ||
catch | ||
{ | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
} | ||
} | ||
|
||
function Find-TestScript | ||
{ | ||
[OutputType([System.IO.FileInfo])] | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Module, | ||
|
||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[ValidateSet('Unit','Integration','Acceptance')] | ||
[string]$Type | ||
) | ||
|
||
Get-ChildItem -Path 'C:\Program Files\WindowsPowerShell\Modules' -Filter "$Module.$Type.Tests.ps1" | ||
} | ||
|
||
function Start-UnitTest | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Module, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TestName, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[hashtable]$AdditionalParams | ||
) | ||
$params = @{ | ||
Module = $Module | ||
Type = 'Unit' | ||
TestName = $TestName | ||
InvokePesterParams = $AdditionalParams | ||
} | ||
Start-PesterTest @params | ||
} | ||
|
||
function Start-IntegrationTest | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Module, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TestName, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[hashtable]$AdditionalParams | ||
) | ||
$params = @{ | ||
Module = $Module | ||
Type = 'Integration' | ||
TestName = $TestName | ||
InvokePesterParams = $AdditionalParams | ||
} | ||
Start-PesterTest @params | ||
} | ||
|
||
function Start-AcceptanceTest | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Module, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TestName, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[hashtable]$AdditionalParams | ||
) | ||
$params = @{ | ||
Module = $Module | ||
Type = 'Acceptance' | ||
TestName = $TestName | ||
InvokePesterParams = $AdditionalParams | ||
} | ||
Start-PesterTest @params | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#requires -Version 4 | ||
|
||
function Get-WeatherForecast | ||
{ | ||
[OutputType([pscustomobject])] | ||
[CmdletBinding()] | ||
param | ||
( | ||
[Parameter(Mandatory)] | ||
[ValidateNotNullOrEmpty()] | ||
[ValidatePattern('^\d{5}$')] | ||
[int]$ZipCode, | ||
|
||
[Parameter()] | ||
[ValidateNotNullOrEmpty()] | ||
[int]$DaysOut = 7 | ||
) | ||
begin | ||
{ | ||
$ErrorActionPreference = 'Stop' | ||
} | ||
process | ||
{ | ||
try | ||
{ | ||
$uri = 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl' | ||
$proxy = New-WebServiceProxy -uri $uri -namespace WebServiceProxy | ||
$latlon = $proxy.LatLonListZipCode($ZipCode) | ||
@($latlon).foreach({ | ||
$l = $_ | ||
$a = $l.dwml.latlonlist -split ',' | ||
$lat = $a[0] | ||
$lon = $a[1] | ||
$now = get-date -UFormat %Y-%m-%d | ||
$format = 'Item24hourly' | ||
$weather = $Proxy.NDFDgenByDay($lat,$lon,$now,$DaysOut,$format) | ||
for ($i = 0 ; $i -le $DaysOut - 1; $i++) { | ||
[pscustomobject]@{ | ||
“Date” = ((Get-Date).addDays($i)).tostring(“MM/dd/yyyy”) ; | ||
“maxTemp” = $weather.dwml.data.parameters.temperature[0].value[$i] ; | ||
“minTemp” = $weather.dwml.data.parameters.temperature[1].value[$i] ; | ||
“Summary” = $weather.dwml.data.parameters.weather.”weather-conditions”[$i].”Weather-summary” | ||
} | ||
} | ||
}) | ||
} | ||
catch | ||
{ | ||
$PSCmdlet.ThrowTerminatingError($_) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<unattend xmlns="urn:schemas-microsoft-com:unattend"> | ||
<settings pass="windowsPE"> | ||
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<SetupUILanguage> | ||
<UILanguage>en-US</UILanguage> | ||
</SetupUILanguage> | ||
<InputLocale>en-US</InputLocale> | ||
<SystemLocale>en-US</SystemLocale> | ||
<UILanguage>en-US</UILanguage> | ||
<UserLocale>en-US</UserLocale> | ||
</component> | ||
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<DiskConfiguration> | ||
<Disk wcm:action="add"> | ||
<CreatePartitions> | ||
<!-- System partition --> | ||
<CreatePartition wcm:action="add"> | ||
<Order>1</Order> | ||
<Size>350</Size> | ||
<Type>Primary</Type> | ||
</CreatePartition> | ||
<!-- Windows partition --> | ||
<CreatePartition wcm:action="add"> | ||
<Order>2</Order> | ||
<Extend>true</Extend> | ||
<Type>Primary</Type> | ||
</CreatePartition> | ||
</CreatePartitions> | ||
<ModifyPartitions> | ||
<ModifyPartition wcm:action="add"> | ||
<Order>1</Order> | ||
<PartitionID>1</PartitionID> | ||
<Label>System</Label> | ||
<Format>NTFS</Format> | ||
<Active>true</Active> | ||
</ModifyPartition> | ||
<ModifyPartition wcm:action="add"> | ||
<Order>2</Order> | ||
<PartitionID>2</PartitionID> | ||
<Format>NTFS</Format> | ||
<Label>Windows</Label> | ||
</ModifyPartition> | ||
</ModifyPartitions> | ||
<DiskID>0</DiskID> | ||
<WillWipeDisk>true</WillWipeDisk> | ||
</Disk> | ||
<WillShowUI>OnError</WillShowUI> | ||
</DiskConfiguration> | ||
<ImageInstall> | ||
<OSImage wcm:action="add"> | ||
<InstallTo> | ||
<DiskID>0</DiskID> | ||
<PartitionID>2</PartitionID> | ||
</InstallTo> | ||
<InstallFrom> | ||
<MetaData wcm:action="add"> | ||
<Value>Windows Server 2012 R2 SERVERSTANDARD</Value> | ||
<Key>/IMAGE/NAME</Key> | ||
</MetaData> | ||
</InstallFrom> | ||
<InstallToAvailablePartition>false</InstallToAvailablePartition> | ||
</OSImage> | ||
</ImageInstall> | ||
<UserData> | ||
<ProductKey> | ||
<WillShowUI>OnError</WillShowUI> | ||
<Key>PNCRQ-TYDVC-QC8X9-Y24Q3-3PC2B</Key> | ||
</ProductKey> | ||
<AcceptEula>true</AcceptEula> | ||
</UserData> | ||
</component> | ||
</settings> | ||
<settings pass="specialize"> | ||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<ComputerName>TESTDC</ComputerName> | ||
<RegisteredOwner>Adam Bertram</RegisteredOwner> | ||
<AutoLogon> | ||
<Password> | ||
<Value>cABAACQAJAB3ADAAcgBkADEAMgBQAGEAcwBzAHcAbwByAGQA</Value> | ||
<PlainText>false</PlainText> | ||
</Password> | ||
<Enabled>true</Enabled> | ||
<Username>Administrator</Username> | ||
</AutoLogon> | ||
</component> | ||
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<RunSynchronous> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>2</Order> | ||
<Path>cmd /c net user administrator /active:yes</Path> | ||
<Description>enable administrator</Description> | ||
</RunSynchronousCommand> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>3</Order> | ||
<Description>Set NIC IP and DNS</Description> | ||
<Path>powershell -NoProfile -Command "$i=(Get-NetAdapter).ifIndex;New-NetIPAddress -IPAddress '192.168.0.156' -PrefixLength 24 -InterfaceIndex $i;Set-DnsClientServerAddress -InterfaceIndex $i -ServerAddresses '192.168.0.156'"</Path> | ||
</RunSynchronousCommand> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Order>4</Order> | ||
<Description>Disable Firewall</Description> | ||
<Path>NetSh Advfirewall set allprofiles state off</Path> | ||
</RunSynchronousCommand> | ||
<RunSynchronousCommand wcm:action="add"> | ||
<Path>cmd /c reg add "HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" /v ExecutionPolicy /t REG_SZ /d Unrestricted /f</Path> | ||
<Description>Configure Powershell security settings</Description> | ||
<Order>1</Order> | ||
</RunSynchronousCommand> | ||
</RunSynchronous> | ||
</component> | ||
</settings> | ||
<settings pass="oobeSystem"> | ||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<UserAccounts> | ||
<AdministratorPassword> | ||
<Value>cABAACQAJAB3ADAAcgBkADEAMgBBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value> | ||
<PlainText>false</PlainText> | ||
</AdministratorPassword> | ||
</UserAccounts> | ||
<AutoLogon> | ||
<Password> | ||
<Value>cABAACQAJAB3ADAAcgBkADEAMgBQAGEAcwBzAHcAbwByAGQA</Value> | ||
<PlainText>false</PlainText> | ||
</Password> | ||
<Enabled>true</Enabled> | ||
<Username>administrator</Username> | ||
</AutoLogon> | ||
</component> | ||
</settings> | ||
<cpi:offlineImage cpi:source="wim:c:/en_windows_server_2012_r2_with_update_x64_dvd_4065220/sources/install.wim#Windows Server 2012 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> | ||
</unattend> |