PowerPack tips and examples
All PowerPacks scripts must end with Exit-PSScript $Error or they will fail.
Exit-PSScript $Error
How to suppress recording any errors when using PowerShell commands (if supported).
Get-Process -Name 'dummy' -ErrorAction:Ignore
Create Functions - it is recommended to use the “approved” naming convention when creating functions. (Verb-Noun)
# get list of approved verbs
Get-Verb
# simple function example
function Start-InitializeSDK {
$script:cms=New-Object -ComObject "CapaInstaller.SDK"
$script:cms.SetDatabaseSettings($global:databaseserver,$global:database,$false)
Write-Host $script:cms.GetDllVersion()
$script:cms.SetDefaultManagementPoint($global:cmpid)
$script:cms.GetManagementPoints()
$script:cms.SetSplitter("|")
}
When calling Functions never use “( )” parentheses.
How to encrypt passwords.
Join domain.
Enable local administrator account and set password.