Define DynamicKeyword 'ExecTest'
Note: Don't copy&paste from following code. PowerShell SyntaxHighlighter remove some lines. Instead, use RAW view.
#Requires -Version 4.0
Set-StrictMode -Version Latest
$username = "ansible" | |
$password = ConvertTo-SecureString "1234QWer" -AsPlainText -Force | |
try { | |
Get-LocalUser -Name $username -ErrorAction Stop | |
} | |
catch { | |
New-LocalUser -Name $username -Password $password -FullName $username -Description $username -PasswordNeverExpires | |
} |
Function Load-ConfigMgrAssemblies { | |
Param( | |
$AdminConsoleDirectory = ($env:SMS_ADMIN_UI_PATH | Split-Path -Parent) | |
) | |
#Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\DcmObjectModel.dll" | |
$filesToLoad = "Microsoft.ConfigurationManagement.ApplicationManagement.dll","AdminUI.WqlQueryEngine.dll", "AdminUI.DcmObjectWrapper.dll","DcmObjectModel.dll","AdminUI.AppManFoundation.dll","AdminUI.WqlQueryEngine.dll","Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll","Microsoft.ConfigurationManagement.ManagementProvider.dll","Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll" | |
Set-Location $AdminConsoleDirectory | |
[System.IO.Directory]::SetCurrentDirectory($AdminConsoleDirectory) |
#Requires -RunAsAdministrator | |
#Requires -Version 3.0 | |
#References: | |
#Getting Started with Nano Server <https://technet.microsoft.com/en-us/library/mt126167.aspx> | |
#Quick Guide - Deploying Nano Server using PowerShell <http://deploymentresearch.com/Research/Post/479/Quick-Guide-Deploying-Nano-Server-using-PowerShell> | |
param ( | |
#[ValidateScript({ Test-Path $_ })] | |
$ConvertWindowsImageScriptPath = 'D:\work\NanoServerSetup\Convert-WindowsImage.ps1' |
Describe 'Unit testing the helper functions in self contained script' { | |
BeforeAll { | |
# Using AST to parse the function definitions from the self contained script. | |
# Then, save the script of the Pester test drive. | |
$FilePath = Join-Path -Path '.' -ChildPath 'ScriptWithFunction.ps1' | |
$ast = [System.Management.Automation.Language.Parser]::ParseFile($FilePath, [ref]$null, [ref]$null) | |
$functionDefinition = $ast.FindAll( { | |
param([System.Management.Automation.Language.Ast] $AstInput) | |
$AstInput -is [System.Management.Automation.Language.FunctionDefinitionAst] -and | |
# Class methods have a FunctionDefinitionAst under them as well, but we don't want them. |
function Invoke-SCCMRunScript { | |
param( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$SiteServer, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$Namespace, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] |
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"newVMName": { | |
"type": "string", | |
"defaultValue": "ConfigMgrTP" | |
}, | |
"labName": { | |
"type": "string", |
############################################## | |
############## Script Info ################### | |
############################################## | |
## Created By : Dan Cook 2017 ######## | |
############################################## | |
<# | |
Version Info : | |
0.1 - 25/05/2017 - Creates a graphvis diagram and accompanying DOT code file | |
for an SCCM application dependency tree, by querying the |
Function New-WPFMessageBox { | |
# For examples for use, see my blog: | |
# https://smsagent.wordpress.com/2017/08/24/a-customisable-wpf-messagebox-for-powershell/ | |
# Define Parameters | |
[CmdletBinding()] | |
Param | |
( | |
# The popup Content |