-
Notifications
You must be signed in to change notification settings - Fork 1
Functions
PSRedstone 2023.4.25.235
functions are fully documented in this article.
This article has been made availble for your convenience and for easy searching.
The same information is availble using the Get-Help
function in PowerShell.
The sections of this document have been automatically generated with platyPS and glued together into a single document.
To review documentation for a previous version of PSRedstone, review the history.
Table of Contents:
- Assert-RedstoneIsElevated
- Assert-RedstoneIsMutexAvailable
- Assert-RedstoneIsNonInteractiveShell
- Close-RedstoneProgram
- Dismount-RedstoneRegistryHive
- Dismount-RedstoneWim
- Get-RedstoneExeFileInfo
- Get-RedstoneHashtableValue
- Get-RedstoneInstalledApplication
- Get-RedstoneMsiExitCodeMessage
- Get-RedstoneMsiTableProperty
- Get-RedstoneRegistryKeyAsArray
- Get-RedstoneRegistryKeyAsHashtable
- Get-RedstoneRegistryValueDoNotExpandEnvironmentName
- Get-RedstoneRegistryValueOrDefault
- Get-RedstoneTranslatedErrorCode
- Get-RedstoneUserProfiles
- Install-RedstoneWindowsUpdateAdv
- Invoke-RedstoneCmd
- Invoke-RedstoneDownload
- Invoke-RedstoneElevateCurrentProcess
- Invoke-RedstoneForceEmptyDirectory
- Invoke-RedstoneMSI
- Invoke-RedstoneObjectMethod
- Invoke-RedstonePesterDetect
- Invoke-RedstoneRegistryTakeOwnership
- Invoke-RedstoneRun
- Invoke-RedstoneTouch
- Mount-RedstoneRegistryHive
- Mount-RedstoneWim
- New-RedstoneRedstone
- New-RedstoneScheduledTaskTriggerLogonRunAsUser
- New-RedstoneWim
- Set-RedstoneRegistryHiveItemProperty
- Set-RedstoneRegsitryKeyPermissions
- Show-RedstoneToastNotification
- Stop-RedstoneProcessTree
Is the current process elevated (running as administrator)?
Assert-RedstoneIsElevated [<CommonParameters>]
{{ Fill in the Description }}
Assert-IsElevated
Returns $true
if you're running as an administrator.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[bool]
https://github.com/VertigoRay/PSRedstone/wiki/Functions#assert-iselevated
Wait, up to a timeout value, to check if current thread is able to acquire an exclusive lock on a system mutex.
Assert-RedstoneIsMutexAvailable [-MutexName] <String> [[-MutexWaitTimeInMilliseconds] <Int32>]
[<CommonParameters>]
A mutex can be used to serialize applications and prevent multiple instances from being opened at the same time. Wait, up to a timeout (default is 1 millisecond), for the mutex to become available for an exclusive lock. This is an internal script function and should typically not be called directly.
Assert-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds 500
Assert-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds (New-TimeSpan -Minutes 5).TotalMilliseconds
Assert-IsMutexAvailable -MutexName 'Global\_MSIExecute' -MutexWaitTimeInMilliseconds (New-TimeSpan -Seconds 60).TotalMilliseconds
The name of the system mutex.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The number of milliseconds the current thread should wait to acquire an exclusive lock of a named mutex. Default is: $Redstone.Settings.'Test-IsMutexAvailable'.MutexWaitTimeInMilliseconds A wait time of -1 milliseconds means to wait indefinitely. A wait time of zero does not acquire an exclusive lock but instead tests the state of the wait handle and returns immediately.
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 300000
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Boolean
Copyright â'¸ 2015 - PowerShell App Deployment Toolkit Team
Copyright â'¸ 2023 - Raymond Piller (VertigoRay)
https://github.com/VertigoRay/PSRedstone/wiki/Functions/#assert-ismutexavailable
Is the current process running in a non-interactive shell?
Assert-RedstoneIsNonInteractiveShell [<CommonParameters>]
There are two ways to determine if the current process is in a non-interactive shell:
- See if the user environment is marked as interactive.
- See if PowerShell was launched with the -NonInteractive
Assert-IsNonInteractiveShell
If you're typing this into PowerShell, you should see $false
.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Boolean
- Powershell test for noninteractive mode
- Environment.UserInteractive Property
- About PowerShell.exe: NonInteractive
https://github.com/VertigoRay/PSRedstone/wiki/Functions#assert-isnoninteractiveshell
Close the supplied process.
Close-RedstoneProgram [-Process] <Process> [[-SleepSeconds] <Int32>] [<CommonParameters>]
The supplied process is expected to be a program and have a visible window.
This function will attempt to safely close the window before force killing the process.
It's a little safer than just doing a Stop-Process -Force
.
Get-Process code | Close-Program
$codes = Get-Process code; $codes | Close-Program -SleepSeconds [math]::Ceiling($codes.Count / 2)
Process to close.
Type: System.Diagnostics.Process
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
The number of seconds to wait after closing the main window before we force kill. If passing this in a pipeline, this is per pipeline item; otherwise, it is the wait time for all processes.
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Dismount a registry hive.
Dismount-RedstoneRegistryHive [[-Hive] <RegistryKey>]
Dismount a hive to the registry.
Dismount-RegistryHive -Hive $hive
Where $hive
was created with:
$hive = Mount-RegistryHive -DefaultUser
The key object returned from Mount-RegistryHive
.
Type: Microsoft.Win32.RegistryKey
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
[void]
{{ Fill in the Synopsis }}
Dismount-RedstoneWim [-MountPath] <DirectoryInfo> [-LogFileF <FileInfo>] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
Full path for the DISM log with {0} formatter to inject "DISM".
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Path the WIM was mounted.
Type: System.IO.DirectoryInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
Attempt to find the EXE in the provided Path.
Get-RedstoneExeFileInfo [-Path] <String> [<CommonParameters>]
This functions will go through three steps to find the provided EXE:
- Determine if you provided the full path to the EXE or if it's in the current directory.
- Determine if it can be found under any path in $env:PATH.
- Determine if the locations was registered in the registry.
If one of these is true, it'll stop looking and return the IO.FileInfo
of the EXE.
Get-ExeFileInfo 'notepad.exe'
Get-ExeFileInfo 'chrome.exe'
Name of the EXE to search for.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[IO.FileInfo]
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-exefileinfo
This function is purely designed to make things easier when getting a value from a hashtable using a path in string form.
Get-RedstoneHashtableValue [[-Hashtable] <Hashtable>] [[-Path] <String>] [[-Default] <Object>]
This function is purely designed to make things easier when getting a value from a hashtable using a path in string form. It has the added benefit of returning a provided default value if the path doesn't exist.
Get-HashtableValue -Hashtable $vars -Path 'Thing2.This2.That1' -Default 'nope'
Returns 221
from the following $vars
hashtable:
$vars = @{
Thing1 = 1
Thing2 = @{
This1 = 21
This2 = @{
That1 = 221
That2 = 222
That3 = 223
That4 = $null
}
This3 = 23
}
Thing3 = 3
}
Get-HashtableValue -Hashtable $vars -Path 'Thing2.This2.That4' -Default 'nope'
Returns $null
from the following $vars
hashtable:
$vars = @{
Thing1 = 1
Thing2 = @{
This1 = 21
This2 = @{
That1 = 221
That2 = 222
That3 = 223
That4 = $null
}
This3 = 23
}
Thing3 = 3
}
Get-HashtableValue -Hashtable $vars -Path 'Thing2.This4' -Default 'nope'
Returns "nope"
from the following $vars
hashtable:
$vars = @{
Thing1 = 1
Thing2 = @{
This1 = 21
This2 = @{
That1 = 221
That2 = 222
That3 = 223
That4 = $null
}
This3 = 23
}
Thing3 = 3
}
$redstone.GetVar('Thing2.This2.That4', 'nope')
When being used to access $redstone.Vars
there's a built-in method that calls this function a bit easier.
Returns $null
from the following $redstone.Vars
hashtable:
$redstone.Vars = @{
Thing1 = 1
Thing2 = @{
This1 = 21
This2 = @{
That1 = 221
That2 = 222
That3 = 223
That4 = $null
}
This3 = 23
}
Thing3 = 3
}
{{ Fill Hashtable Description }}
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Path Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Default Description }}
Type: System.Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-hashtablevalue
Retrieves information about installed applications.
Get-RedstoneInstalledApplication [[-Name] <String[]>] [-CaseSensitive] [-WildCard] [-IncludeUpdatesAndHotfixes]
[-UninstallRegKeys <String[]>] [<CommonParameters>]
Get-RedstoneInstalledApplication [[-Name] <String[]>] [-CaseSensitive] [-RegEx] [-IncludeUpdatesAndHotfixes]
[-UninstallRegKeys <String[]>] [<CommonParameters>]
Get-RedstoneInstalledApplication [[-Name] <String[]>] [-CaseSensitive] [-Exact] [-IncludeUpdatesAndHotfixes]
[-UninstallRegKeys <String[]>] [<CommonParameters>]
Get-RedstoneInstalledApplication [[-Name] <String[]>] [-CaseSensitive] [-IncludeUpdatesAndHotfixes]
[-UninstallRegKeys <String[]>] [<CommonParameters>]
Get-RedstoneInstalledApplication [-ProductCode <String>] [-IncludeUpdatesAndHotfixes]
[-UninstallRegKeys <String[]>] [<CommonParameters>]
Retrieves information about installed applications by querying the registry. You can specify an application name, a product code, or both. Returns information about application publisher, name & version, product code, uninstall string, quiet uninstall string, install source, location, date, and application architecture.
Get-InstalledApplication -Name 'Adobe Flash'
Get-InstalledApplication -ProductCode '{1AD147D0-BE0E-3D6C-AC11-64F6DC4163F1}'
The name of the application to retrieve information for. Performs a regex match on the application display name by default.
Type: System.String[]
Parameter Sets: Like, Regex, Exact, Eq
Aliases:
Required: False
Position: 1
Default value: *
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill CaseSensitive Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Like, Regex, Exact, Eq
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the named application must be matched using the exact name.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Exact
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies that the named application must be matched using a wildcard search.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Like
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill RegEx Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Regex
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The product code of the application to retrieve information for.
Type: System.String
Parameter Sets: Productcode
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Include matches against updates and hotfixes in results.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Private Parameter; used for debug overrides.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: @(
'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
)
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[hashtable[]]
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-installedapplication
Get message for MSI error code
Get-RedstoneMsiExitCodeMessage [-MsiExitCode] <Int32> [[-MsiLog] <String>] [<CommonParameters>]
Get message for MSI error code by reading it from msimsg.dll
Get-MsiExitCodeMessage -MsiExitCode 1618
{{ Fill MsiExitCode Description }}
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
MSI Log File. Parsed if ErrorCode is 1603.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This is an internal script function and should typically not be called directly.
Copyright â'¸ 2015 - PowerShell App Deployment Toolkit Team
Copyright â'¸ 2023 - Raymond Piller (VertigoRay)
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-msiexitcodemessage
Get all of the properties from a Windows Installer database table or the Summary Information stream and return as a custom object.
Get-RedstoneMsiTableProperty [-Path] <String> [-TransformPath <String[]>] [-Table <String>]
[-TablePropertyNameColumnNum <Int32>] [-TablePropertyValueColumnNum <Int32>] [-ContinueOnError <Boolean>]
[<CommonParameters>]
Get-RedstoneMsiTableProperty [-Path] <String> [-TransformPath <String[]>] [-GetSummaryInformation]
[-ContinueOnError <Boolean>] [<CommonParameters>]
Use the Windows Installer object to read all of the properties from a Windows Installer database table or the Summary Information stream.
# Retrieve all of the properties from the default 'Property' table.
Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -TransformPath 'C:\Package\AppDeploy.mst' Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -TransformPath 'C:\Package\AppDeploy.mst'
# Retrieve all of the properties from the 'Property' table and then pipe to Select-Object to select the ProductCode property.
Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -TransformPath 'C:\Package\AppDeploy.mst' -Table 'Property' | Select-Object -ExpandProperty ProductCode Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -TransformPath 'C:\Package\AppDeploy.mst' -Table 'Property' | Select-Object -ExpandProperty ProductCode
# Retrieves the Summary Information for the Windows Installer database.
Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -GetSummaryInformation Get-MsiTableProperty -Path 'C:\Package\AppDeploy.msi' -GetSummaryInformation
The fully qualified path to an database file. Supports .msi and .msp files.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The fully qualified path to a list of MST file(s) which should be applied to the MSI file.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the the MSI table from which all of the properties must be retrieved. Default is: 'Property'.
Type: System.String
Parameter Sets: TableInfo
Aliases:
Required: False
Position: Named
Default value: $(if ([IO.Path]::GetExtension($Path) -eq '.msi') { 'Property' } else { 'MsiPatchMetadata' })
Accept pipeline input: False
Accept wildcard characters: False
Specify the table column number which contains the name of the properties. Default is: 1 for MSIs and 2 for MSPs.
Type: System.Int32
Parameter Sets: TableInfo
Aliases:
Required: False
Position: Named
Default value: $(if ([IO.Path]::GetExtension($Path) -eq '.msi') { 1 } else { 2 })
Accept pipeline input: False
Accept wildcard characters: False
Specify the table column number which contains the value of the properties. Default is: 2 for MSIs and 3 for MSPs.
Type: System.Int32
Parameter Sets: TableInfo
Aliases:
Required: False
Position: Named
Default value: $(if ([IO.Path]::GetExtension($Path) -eq '.msi') { 2 } else { 3 })
Accept pipeline input: False
Accept wildcard characters: False
Retrieves the Summary Information for the Windows Installer database. Summary Information property descriptions: https://msdn.microsoft.com/en-us/library/aa372049(v=vs.85).aspx
Type: System.Management.Automation.SwitchParameter
Parameter Sets: SummaryInfo
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Continue if an error is encountered. Default is: $true.
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This is an internal script function and should typically not be called directly.
Copyright â'¸ 2015 - PowerShell App Deployment Toolkit Team
Copyright â'¸ 2023 - Raymond Piller (VertigoRay)
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-msitableproperty
Recursively probe registry key's sub-key's and values and output a sorted array.
Get-RedstoneRegistryKeyAsArray [[-Key] <String>] [[-Hive] <String>]
Recursively probe registry key's sub-key's and values and output a sorted array.
Get-RecursiveRegistryKey 'SOFTWARE\Palo Alto Networks\GlobalProtect'
This is the key path within the hive. Do not include the Hive itself.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is a top-level node in the registry as defined by RegistryHive Enum.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: LocalMachine
Accept pipeline input: False
Accept wildcard characters: False
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-registrykeyasarray
Get the values in a registry key and all sub-keys.
Get-RedstoneRegistryKeyAsHashtable [[-Key] <String>] [-Recurse]
Get the values in a registry key and all sub-keys. This shouldn't be used to pull a massive section of the registry expecting perfect results.
There's a fundamental flaw that I'm unsure how to address with a hashtable. If there's a value and sub-key with the same name at the same key level, the sub-key won't be processed. Because of this, use this function to only return key sections with known/expected structures. Otherwise, consider using Get-RedstoneRegistryKeyAsArray.
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill Key Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Recurse Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-registrykeyashashtable
Get a registry value without expanding environment variables.
Get-RedstoneRegistryValueDoNotExpandEnvironmentName [[-Key] <String>] [[-Value] <String>] [<CommonParameters>]
{{ Fill in the Description }}
Get-RegistryValueDoNotExpandEnvironmentName 'HKCU:\Thing Foo'
{{ Fill Key Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Value Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[bool]
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-registryvaluedonotexpandenvironmentname
Get-RedstoneRegistryValueOrDefault [[-RegistryKey] <String>] [-RegistryValue] <String> [-DefaultData] <Object>
[-RegistryKeyRoot <String>] [-DoNotExpand] [-OnlyUseDefaultSettings <Boolean>] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill RegistryKey Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill RegistryValue Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill DefaultData Description }}
Type: System.Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill RegistryKeyRoot Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Do Not Expand Environment Variables.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
For development.
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-registryvalueordefault
Get-RedstoneTranslatedErrorCode [-ErrorCode] <Win32Exception> [-MECM] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill ErrorCode Description }}
Type: System.ComponentModel.Win32Exception
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill MECM Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.ComponentModel.Win32Exception
https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.win32exception
https://github.com/VertigoRay/PSRedstone/wiki/Functions#get-translatederrorcode
Simplify the looping through user profiles and user registries.
Get-RedstoneUserProfiles [[-Redstone] <Redstone>] [-AllProfiles] [[-DomainSid] <String>]
[[-NotDomainSid] <String>] [-AddDefaultUser] [-IncludeUserRegKey]
Simplify the looping through user profiles and user registries by calling this function that gets what you need quickly.
Each user profile that is returned will contain information in the following hashtable:
@{
Domain = 'CONTOSO'
Username = 'jsmith'
Path = [IO.DirectoryInfo] 'C:\Users\jsmith'
SID = 'S-1-5-21-1111111111-2222222222-3333333333-123456'
RegistryKey = [Microsoft.Win32.RegistryKey] 'HKEY_USERS\S-1-5-21-1111111111-2222222222-3333333333-123456'
}
foreach ($profilePath in (Get-UserProfiles)) { $profilePath }
Provide the redstone class variable so we don't have to create a new one for you.
Type: Redstone
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Include all user profiles, including service accounts. Otherwise just S-1-5-21 User Accounts would be included.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Filter for the provided Sid.
If an *
is not included at the end, it will be added.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Filter out the provided Sid.
If an *
is not included at the end, it will be added.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Include the default User.
Keep in mind, no Domain or SID information will be provided for the default user, and the username will be DEFAULT
.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill IncludeUserRegKey Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This is an advanced function for scheduling the install and reboot Windows Updates. It utilizes and augments functionality provided by PSWindowsUpdate.
Install-RedstoneWindowsUpdateAdv [-LastDeploymentChangeThresholdDays <Int32>] [-ScheduleJob <DateTime>]
[-ScheduleReboot <DateTime>] [-ToastNotification <Hashtable>] [-FixWUAU] [<CommonParameters>]
Install-RedstoneWindowsUpdateAdv [-NoPSWindowsUpdate] [-ToastNotification <Hashtable>] [-FixWUAU]
[<CommonParameters>]
This advanced function for installing Windows Updates will try to fix Windows Updates, if desired, and fail back to non-PowerShell mechanisms for forcing Windows Updates. It utilizes and augments functionality provided by PSWindowsUpdate.
If you want PSWindowsUpdate to send a report, you can use PSDefaultParameterValues to make that happen:
$PSDefaultParameterValues.Set_Item('Install-WindowsUpdate:SendReport', $true)
$PSDefaultParameterValues.Set_Item('Install-WindowsUpdate:SendHistory', $true)
$PSDefaultParameterValues.Set_Item('Install-WindowsUpdate:PSWUSettings', @{
SmtpServer = 'smtp.sendgrid.net'
Port = 465
UseSsl = $true
From = '{1} \<{0}@mailinator.com>' -f (& HOSTNAME.EXE), $env:ComputerName
To = '[email protected]'
})
Install-WindowsUpdateAdv
This will install all available updates now and restart now.
Install-WindowsUpdateAdv -FixWUAU
This will attempt to fix the WUAU service, install all available updates now, and restart immediately afterwards.
Install-WindowsUpdateAdv -LastDeploymentChangeThresholdDays 30 -FixWUAU
This will attempt to fix the WUAU service, install all available updates now that are more than 30 days old, and restart immediately afterwards.
Install-WindowsUpdateAdv -LastDeploymentChangeThresholdDays 30 -FixWUAU -ScheduleJob ((Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-7) | Get-Date -Format 'O')
This will attempt to fix the WUAU service now, install all available updates today at 5 pm that are more than 30 days old, and restart immediately afterwards.
Install-WindowsUpdateAdv -LastDeploymentChangeThresholdDays 30 -FixWUAU -ScheduleJob ((Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-7) | Get-Date -Format 'O') -ScheduleReboot ((Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-1) | Get-Date -Format 'O')
This will attempt to fix the WUAU service now, install all available updates today at 5 pm that are more than 30 days old, and restart today at 11 pm.
Install-WindowsUpdateAdv -LastDeploymentChangeThresholdDays 30 -FixWUAU -ScheduleJob $scheduleJob -ScheduleReboot $scheduleReboot -ToastNotification $toastNotification
This will show a toast notification for any logged on users, attempt to fix the WUAU service now, install all available updates today at 5 pm that are more than 30 days old, and restart today at 11 pm. The variables were defined like this:
$scheduleJob = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-7) | Get-Date -Format 'O' # 5pm today
$scheduleReboot = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-1) | Get-Date -Format 'O' # 11pm today
$toastNotification = @{
ToastNotifier = 'Tech Solutions: Endpoint Solutions Engineering'
ToastTitle = 'Windows Update'
ToastText = 'This computer is at least 30 days overdue for {0} Windows Update{1}.
{2} being forced on your system {3}.
A reboot may occur {4}.'
ToastTextFormatters = @(
@($null, 's')
@('The update is', 'Updates are')
@(('on {0}' -f ($scheduleJob | Get-Date -Format (Get-Culture).DateTimeFormat.FullDateTimePattern)), 'now')
@(('on {0}' -f ($scheduleReboot | Get-Date -Format (Get-Culture).DateTimeFormat.FullDateTimePattern)), 'immediately afterwards')
)
}
Install-WindowsUpdateAdv -FixWUAU -NoPSWindowsUpdate
This will attempt to fix the WUAU service, install all available updates now, and restart immediately afterwards.
When using PSWindowsUpdate
, this will check the LastDeploymentChangeTime
and install updates past the threshold.
Type: System.Int32
Parameter Sets: PSWindowsUpdate
Aliases:
Required: False
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Schedule with a valid [datetime]
value.
I suggest using Get-Date -Format O
to get a convertable string.
$scheduleJob = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-7) | Get-Date -Format 'O' # 5pm today
Type: System.DateTime
Parameter Sets: PSWindowsUpdate
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Schedule with a valid [datetime]
value.
I suggest using Get-Date -Format O
to get a convertable string.
$scheduleReboot = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-1) | Get-Date -Format 'O' # 11pm today
Type: System.DateTime
Parameter Sets: PSWindowsUpdate
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Do NOT install the PSWindowsUpdate module. When this option is used, none of the advanced scheduling or reporting options are available.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: NoPSWindowsUpdate
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
If this parameter is not provided, not Toast Notification will be shown. A hashtable used to splat into the PSRedstone Show-ToastNotification function.
The ToastText
parameter will be formatted with:
$updateCount
1.
$ToastNotification.ToastTextFormatters[0][$updateCount -gt 1]
2.
$ToastNotification.ToastTextFormatters[1][$updateCount -gt 1]
3.
$ToastNotification.ToastTextFormatters[2][$ScheduleJob -as [bool]]
4.
$ToastNotification.ToastTextFormatters[3][$ScheduleReboot -as [bool]]
Here's an example:
$lastDeploymentChangeThresholdDays = 30
$scheduleJob = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-7) | Get-Date -Format 'O' # 5pm today
$scheduleReboot = (Get-Date -Format 'MM-dd-yyyy' | Get-Date).AddDays(1).AddHours(-1) | Get-Date -Format 'O' # 11pm today
$toastNotification = @{
ToastNotifier = 'Tech Solutions: Endpoint Solutions Engineering'
ToastTitle = 'Windows Update'
ToastText = 'This computer is at least 30 days overdue for {0} Windows Update{1}.
{2} being forced on your system {3}.
A reboot may occur {4}.'
ToastTextFormatters = @(
@($null, 's')
@('The update is', 'Updates are')
@(('on {0}' -f ($scheduleJob | Get-Date -Format (Get-Culture).DateTimeFormat.FullDateTimePattern)), 'now')
@(('on {0}' -f ($scheduleReboot | Get-Date -Format (Get-Culture).DateTimeFormat.FullDateTimePattern)), 'immediately afterwards')
)
}
When $toastNotification
is passed to this function, and there are five Windows Updates past due, it will result in a Toast Notification like this:
Tech Solutions: Endpoint Solutions Engineering
This computer is at least 30 days overdue for 5 Windows Updates. Updates are being forced on your system on Saturday, February 11, 2023 5:00:00 PM. Reboot will occur on Saturday, February 11, 2023 11:00:00 PM.
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Attempt to fix the WUAU service.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Runs the given command in ComSpec (aka: Command Prompt).
Invoke-RedstoneCmd [-Cmd] <String> [-KeepOpen] [-StringMod] [-Quiet] [-DisableAutoRun] [-ANSI] [-Unicode]
[<CommonParameters>]
This just runs a command in ComSpec by passing it to Invoke-Run
.
If you don't need ComSpec to run the command, it's normally best to just use Invoke-Run
.
Returns the same object as Invoke-Run
@{
'Process' = $proc; # The result from Start-Process; as returned from `Invoke-Run`.
'StdOut' = $stdout;
'StdErr' = $stderr;
}
Invoke-Cmd "MKLINK /D Temp C:\Temp"
Under normal usage, the string passed in here just gets appended to cmd.exe /c
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Applies /K instead of /C, but why would you want to do this?
/C Carries out the command specified by string and then terminates /K Carries out the command specified by string but remains
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Applies /S: Modifies the treatment of string after /C or /K (run cmd.exe below)
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Applies /Q: Turns echo off
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Applies /D: Disable execution of AutoRun commands from registry (see below)
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Applies /A: Causes the output of internal commands to a pipe or file to be ANSI
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Applies /U: Causes the output of internal commands to a pipe or file to be Unicode
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[Hashtable] As returned from
Invoke-Run.
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-cmd
Download a file and validate the checksum.
Invoke-RedstoneDownload [-Uri] <Uri> -OutFile <FileInfo> [-Checksum <String>] [<CommonParameters>]
Invoke-RedstoneDownload [-Uri] <Uri> -OutFolder <DirectoryInfo> [-Checksum <String>] [<CommonParameters>]
Download a file; use a few methods based on performance preference testing:
Start-BitsTransfer
Net.WebClient
Invoke-WebRequest
If the first one fails, the next one will be tried. Target directory will be automatically created. A checksum will be validated if it is supplied.
Invoke-Download 'https://download3.vmware.com/software/CART23FQ4_WIN_2212/VMware-Horizon-Client-2212-8.8.0-21079405.exe' -OutFile (Join-Path $env:Temp 'VMware-Horizon-Client-2212-8.8.0-21079405.exe')
Invoke-Download 'https://download3.vmware.com/software/CART23FQ4_WIN_2212/VMware-Horizon-Client-2212-8.8.0-21079405.exe' -OutFolder $env:Temp
Invoke-Download 'https://download3.vmware.com/software/CART23FQ4_WIN_2212/VMware-Horizon-Client-2212-8.8.0-21079405.exe' -OutFolder $env:Temp -Checksum 'sha256:a0bac35619328f5f9aa56508572f343f7a388286768b31ab95377c37b052e5ac'
Uri to the File to be downloaded.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The full path of the file to be downloaded.
Type: System.IO.FileInfo
Parameter Sets: OutFile
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Folder where you want the file to go. If this is specified, the file name is derived from the last segment of the Uri parameter.
Type: System.IO.DirectoryInfo
Parameter Sets: OutFolder
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
A string containing the Algorithm and the Hash separated by a colon. For example: "SHA256:AA24A85644ECCCAD7098327899A3C827A6BE2AE1474C7958C1500DCD55EE66D8"
The algorithm should be a valid algorithm recognized by Get-FileHash
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-download
Get SeTakeOwnership, SeBackup and SeRestore privileges before executes next lines, script needs Admin privilege
Invoke-RedstoneElevateCurrentProcess [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
Ref: https://stackoverflow.com/a/35843420/17552750
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-elevatecurrentprocess
Invoke-RedstoneForceEmptyDirectory [-Path] <DirectoryInfo> [<CommonParameters>]
{{ Fill in the Description }}
$MountPath.FullName | Invoke-ForceEmptyDirectory
Path to one or more locations.
Type: System.IO.DirectoryInfo
Parameter Sets: (All)
Aliases: PSPath
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-forceemptydirectory
Executes msiexec.exe to perform the following actions for MSI & MSP files and MSI product codes: install, uninstall, patch, repair, active setup.
Invoke-RedstoneMSI [-Action <String>] [-Path] <String> [-Transforms <String[]>] [-Parameters <String[]>]
[-SecureParameters] [-Patches <String[]>] [-LoggingOptions <String>] [-WorkingDirectory <String>]
[-SkipMSIAlreadyInstalledCheck] [-MsiDisplay <String>] [-WindowStyle <String>] [-PassThru <Boolean>]
[-LogFileF <String>] [<CommonParameters>]
Executes msiexec.exe to perform the following actions for MSI & MSP files and MSI product codes: install, uninstall, patch, repair, active setup. If the -Action parameter is set to "Install" and the MSI is already installed, the function will exit. Sets default switches to be passed to msiexec based on the preferences in the XML configuration file. Automatically generates a log file name and creates a verbose log file for all msiexec operations. Expects the MSI or MSP file to be located in the "Files" sub directory of the App Deploy Toolkit. Expects transform files to be in the same directory as the MSI file.
# Installs an MSI
Invoke-MSI 'Adobe_FlashPlayer_11.2.202.233_x64_EN.msi'
# Installs an MSI, applying a transform and overriding the default MSI toolkit parameters
Invoke-MSI -Action 'Install' -Path 'Adobe_FlashPlayer_11.2.202.233_x64_EN.msi' -Transform 'Adobe_FlashPlayer_11.2.202.233_x64_EN_01.mst' -Parameters '/QN'
# Installs an MSI and stores the result of the execution into a variable by using the -PassThru option
[psobject] $ExecuteMSIResult = Invoke-MSI -Action 'Install' -Path 'Adobe_FlashPlayer_11.2.202.233_x64_EN.msi' -PassThru
# Uninstalls an MSI using a product code
Invoke-MSI -Action 'Uninstall' -Path '{26923b43-4d38-484f-9b9e-de460746276c}'
# Installs an MSP
Invoke-MSI -Action 'Patch' -Path 'Adobe_Reader_11.0.3_EN.msp'
$msi = @{
Action = 'Install' Parameters = @( 'USERNAME="{0}"' -f $settings.Installer.UserName 'COMPANYNAME="{0}"' -f $settings.Installer.CompanyName 'SERIALNUMBER="{0}"' -f $settings.Installer.SerialNumber ) }
if ([Environment]::Is64BitOperatingSystem) { Invoke-MSI @msi -Path 'Origin2016Sr2Setup32and64Bit.msi' } else { Invoke-MSI @msi -Path 'Origin2016Sr2Setup32Bit.msi' }
The action to perform. Options: Install, Uninstall, Patch, Repair, ActiveSetup.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Install
Accept pipeline input: False
Accept wildcard characters: False
The path to the MSI/MSP file or the product code of the installed MSI.
Type: System.String
Parameter Sets: (All)
Aliases: FilePath
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The name of the transform file(s) to be applied to the MSI. Relational paths from the working dir, then the MSI are looked for ... in that order. Multiple transforms can be specified; separated by a comma.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Overrides the default parameters specified in the XML configuration file. Install default is: "REBOOT=ReallySuppress /QB!". Uninstall default is: "REBOOT=ReallySuppress /QN".
Type: System.String[]
Parameter Sets: (All)
Aliases: Arguments
Required: False
Position: Named
Default value: @('REBOOT=ReallySuppress')
Accept pipeline input: False
Accept wildcard characters: False
Hides all parameters passed to the MSI or MSP file from the toolkit Log file.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The name of the patch (msp) file(s) to be applied to the MSI for use with the "Install" action. The patch file is expected to be in the same directory as the MSI file.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Overrides the default logging options specified in the XML configuration file. Default options are: "/log" (aka: "/L*v")
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: /log
Accept pipeline input: False
Accept wildcard characters: False
Overrides the working directory. The working directory is set to the location of the MSI file.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $PWD.Path
Accept pipeline input: False
Accept wildcard characters: False
Skips the check to determine if the MSI is already installed on the system. Default is: $false.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Overrides the default MSI Display Settings.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: /qn
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill WindowStyle Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Hidden
Accept pipeline input: False
Accept wildcard characters: False
Returns ExitCode, StdOut, and StdErr output from the process.
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
When using [Redstone], this will be overridden via $PSDefaultParameters.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: "${env:Temp}\Invoke-Msi.{1}.{0}.log"
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Collections.Hashtable
Copyright (C) 2015 - PowerShell App Deployment Toolkit Team Copyright (C) 2023 - Raymond Piller (VertigoRay)
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-msi
Invoke method on any object.
Invoke-RedstoneObjectMethod [-InputObject] <Object> [-MethodName] <String> [[-ArgumentList] <Object[]>]
[<CommonParameters>]
Invoke-RedstoneObjectMethod [-InputObject] <Object> [-MethodName] <String> [-Parameter] <Hashtable>
[<CommonParameters>]
Invoke method on any object with or without using named parameters.
$ShellApp = New-Object -ComObject 'Shell.Application'
$null = Invoke-ObjectMethod -InputObject $ShellApp -MethodName 'MinimizeAll'
Minimizes all windows.
$ShellApp = New-Object -ComObject 'Shell.Application'
$null = Invoke-ObjectMethod -InputObject $ShellApp -MethodName 'Explore' -Parameter @{'vDir'='C:\Windows'}
Opens the C:\Windows folder in a Windows Explorer window.
Specifies an object which has methods that can be invoked.
Type: System.Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the name of a method to invoke.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Argument to pass to the method being executed. Allows execution of method without specifying named parameters.
Type: System.Object[]
Parameter Sets: Positional
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Argument to pass to the method being executed. Allows execution of method by using named parameters.
Type: System.Collections.Hashtable
Parameter Sets: Named
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
This is an internal script function and should typically not be called directly.
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-objectmethod
Run a scriptblock that contains Pester tests that can be used for MECM Application Detection.
Invoke-RedstonePesterDetect [-PesterScriptBlock] <ScriptBlock> [[-PesterScriptBlockParam] <Hashtable>]
[[-PublisherProductVersion] <String>] [-DevMode] [<CommonParameters>]
$ppv = 'VertigoRay Assert-IsElevated 1.2.3'
$sb = {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]
$FunctionName
)
Describe $FunctionName {
It 'Return Boolean' {
{
& $FunctionName | Should -BeOfType 'System.Boolean'
} | Should -Not -Throw
}
}
}
$params = @{
FunctionName = 'Assert-IsElevated'
}
Invoke-PesterDetect -PesterScriptBlock $sb -PesterScriptBlockParam $params -PublisherProductVersion $ppv
Invoke-PesterDetect -PesterScriptBlock $sb -PesterScriptBlockParam $params -PublisherProductVersion $ppv
This will run the PowerShell code block below returning ONLY the Detection SUCCESSFUL
message if the detection was successful.
Detection SUCCESSFUL: VertigoRay Assert-IsElevated 1.2.3
It will return nothing if the detection failed.
If you want to see where detection is failing, add the DevMode
parameter.
Note: if your want to see what the variables are set to, take a look at the Description.
Invoke-PesterDetect -PesterScriptBlock $sb -PesterScriptBlockParam $params -PublisherProductVersion $ppv -DevMode
This will the pass with verbose output.
Pester v5.3.3
Starting discovery in 1 files.
Discovery found 1 tests in 25ms.
Running tests.
Describing Assert-IsElevated
[+] Return Boolean 26ms (15ms|11ms)
Tests completed in 174ms
Tests Passed: 1, Failed: 0, Skipped: 0 NotRun: 0
Detection SUCCESSFUL: VertigoRay Assert-IsElevated 1.2.3
Note: if your want to see what the variables are set to, take a look at the Description.
Invoke-PesterDetect -PesterScriptBlock $sb -PesterScriptBlockParam @{ FunctionName = 'This-DoesNotExist' } -PublisherProductVersion $ppv -DevMode
This will fail with verbose output.
This is useful in development, but you wouldn't want to send this to production.
The reason is described in the DevMode
parameter section.
Pester v5.4.0
Starting discovery in 1 files.
Discovery found 1 tests in 48ms.
Running tests.
Describing This-DoesNotExist
[-] Return Boolean 250ms (241ms|9ms)
Expected no exception to be thrown, but an exception "The term 'This-DoesNotExist' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again." was thrown from line:12 char:19
+ & $FunctionName | Should -BeOfType 'System.Boolean'
+ ~~~~~~~~~~~~~.
at } | Should -Not -Throw, :13
at \<ScriptBlock>, \<No file>:11
Tests completed in 593ms
Tests Passed: 0, Failed: 1, Skipped: 0 NotRun: 0
WARNING: [DEV MODE] Detection FAILED: VertigoRay Assert-IsElevated 1.2.3
Note: if your want to see what the variables are set to, take a look at the Description.
Pass in a ScriptBlock that contains a fully functional Pester test. Here's a simple example of creating the ScriptBlock:
$sb = {
Describe 'Assert-IsElevated' {
It 'Return Boolean' {
{
Assert-IsElevated | Should -BeOfType 'System.Boolean'
} | Should -Not -Throw
}
}
}
Invoke-PesterDetect -PesterScriptBlock $sb
Type: System.Management.Automation.ScriptBlock
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This allows you to pass parameters into your ScriptBlock.
Here's a simple example of creating the ScriptBlock with a parameter and passing a value into it.
This PowerShell code is functionally identical to the code in the PesterScriptBlock
parameter.:
$sb = {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]
$FunctionName
)
Describe $FunctionName {
It 'Return Boolean' {
{
& $FunctionName | Should -BeOfType 'System.Boolean'
} | Should -Not -Throw
}
}
}
$params = @{
FunctionName = 'Assert-IsElevated'
}
Invoke-PesterDetect -PesterScriptBlock $sb -PesterScriptBlockParam $params
Type: System.Collections.Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: @{}
Accept pipeline input: False
Accept wildcard characters: False
This a string containing the Publisher, Product, and Version separated by spaces.
$PublisherProductVersion = "$($settings.Publisher) $($settings.Product) $($settings.Version)"
Really, you can provide whatever you want here, whatever you provide will be put on the end of a successful detection message. For example, if you set this to "Peanut Brittle" because you think it's amusing, your successful detection message will be:
Detection SUCCESSFUL: Peanut Brittle
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: :)
Accept pipeline input: False
Accept wildcard characters: False
This script allows additional output when you're in you development environment. This is important to address because detections scripts have very strict StdOut requirements.
$devMode = if ($MyInvocation.MyCommand.Name -eq 'detect.ps1') { $true } else { $false }
This example assumes that in your development environment, you've named your detections script detect.ps1
.
This is the InvocationName when we running the dev version of the script, like in Windows Sandbox.
When SCCM calls detection, the detection script is put in a file named as a guid.
i.e.
fae94777-2c0d-4dd0-94f0-407f7cd07858.ps1
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Invoke-RedstoneRegistryTakeOwnership [[-RootKey] <String>] [-Key] <String> [[-Sid] <SecurityIdentifier>]
[[-Recurse] <Boolean>] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill RootKey Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Key Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Sid Description }}
Type: System.Security.Principal.SecurityIdentifier
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Recurse Description }}
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Boolean
Ref: https://stackoverflow.com/a/35843420/17552750
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-registrytakeownership
Runs the given command.
Invoke-RedstoneRun [-Cmd] <String> [-CaptureConsoleOut] [-WorkingDirectory <String>] [-PassThru <Boolean>]
[-Wait <Boolean>] [-WindowStyle <String>] [-LogFile <FileInfo>] [<CommonParameters>]
Invoke-RedstoneRun -FilePath <String> [-ArgumentList <String[]>] [-CaptureConsoleOut]
[-WorkingDirectory <String>] [-PassThru <Boolean>] [-Wait <Boolean>] [-WindowStyle <String>]
[-LogFile <FileInfo>] [<CommonParameters>]
This command sends a single command to Start-Process
in a way that is standardized.
For convenience, you can use the Cmd
parameter, passing a single string that contains your executable and parameters; see examples.
The command will return a [hashtable]
including the Process results, standard output, and standard error:
@{
'Process' = $proc; # The result from Start-Process.
'StdOut' = $stdout; # This is an array, as returned from `Get-Content`.
'StdErr' = $stderr; # This is an array, as returned from `Get-Content`.
}
This function has been vetted for several years, but if you run into issues, try using Start-Process
.
$result = Invoke-Run """${firefox_setup_exe}"" /INI=""${ini}"""
Use Cmd
parameter
$result = Invoke-Run -FilePath $firefox_setup_exe -ArgumentList @("/INI=""${ini}""")
Use FilePath
and ArgumentList
parameters
$result.Process.ExitCode
Get the ExitCode
This is the command you wish to run, including arguments, as a single string.
Type: System.String
Parameter Sets: Cmd
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the optional path and file name of the program that runs in the process. Enter the name of an executable file or of a document, such as a .txt or .doc file, that is associated with a program on the computer.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.String
Parameter Sets: FilePath
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies parameters or parameter values to use when this cmdlet starts the process.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.String[]
Parameter Sets: FilePath
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill CaptureConsoleOut Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Specifies the location of the executable file or document that runs in the process. The default is the current folder.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Returns a process object for each process that the cmdlet started. By default, this cmdlet does generate output.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
Indicates that this cmdlet waits for the specified process to complete before accepting more input. This parameter suppresses the command prompt or retains the window until the process finishes.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: True
Accept pipeline input: False
Accept wildcard characters: False
Specifies the state of the window that is used for the new process. The acceptable values for this parameter are: Normal, Hidden, Minimized, and Maximized.
Passes Directly to Start-Process
; see Get-Help Start-Process
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Hidden
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill LogFile Description }}
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[hashtable]
https://github.com/VertigoRay/PSRedstone/wiki/Functions#invoke-run
Touch - change file timestamps.
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-NoCreate] [-PassThru] [<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-NoCreate] [-WriteTimeOnly] [-Reference <FileInfo>] [-PassThru]
[<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-AccessTimeOnly] [-NoCreate] [-Reference <FileInfo>] [-PassThru]
[<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-NoCreate] [-Date <DateTime>] [-WriteTimeOnly] [-PassThru]
[<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-AccessTimeOnly] [-NoCreate] [-Date <DateTime>] [-PassThru]
[<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-NoCreate] [-WriteTimeOnly] [-PassThru] [<CommonParameters>]
Invoke-RedstoneTouch [-Path] <FileInfo[]> [-AccessTimeOnly] [-NoCreate] [-PassThru] [<CommonParameters>]
Update the access and modification times of the Path to the current time. A path argument that does not exist is created empty, unless -c or is supplied.
Invoke-Touch 'C:\Temp\foo.txt'
Update the access and modification times of foo.txt
to the current time.
Get-ChildItem $env:Temp -File | Invoke-Touch
Update the access and modification times of all files in the temp directory to the current time.
Not specifying the -File
parameter may cause directories to be passed in; this will cause a ParameterBindingException
to be thrown.
Get-ChildItem $env:Temp -File | Invoke-Touch -PassThru | Invoke-MoreActions
Update the access and modification times of all files in the temp directory to the current time and pass the file info through on the pipeline.
Not specifying the -File
parameter may cause directories to be passed in; this will cause a ParameterBindingException
to be thrown.
Specifies a path to a file.
Type: System.IO.FileInfo[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Change only the access time.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: ReferenceAccessTimeOnly, DateAccessTimeOnly, NowAccessTimeOnly
Aliases: a
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Do not create any files.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: c
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Use instead of current time.
Type: System.DateTime
Parameter Sets: DateWriteTimeOnly, DateAccessTimeOnly
Aliases: d
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Change only the modification time.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: ReferenceWriteTimeOnly, DateWriteTimeOnly, NowWriteTimeOnly
Aliases: m
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Use this file's times instead of current time.
Type: System.IO.FileInfo
Parameter Sets: ReferenceWriteTimeOnly, ReferenceAccessTimeOnly
Aliases: r
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Return the IO.FileInfo for the touched file.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.IO.FileInfo
Ref:
Mount a registry hive.
Mount-RedstoneRegistryHive [[-FilePath] <FileInfo>] [[-Hive] <String>] [-DefaultUser] [-DoNotAutoDismount]
Mount a hive to the registry. Return the destination in the registry where the hive was mounted.
If the DefaultUser parameter is provided, then all other parameters are discarded.
$hive = Mount-RegistryHive -DefaultUser
$hive = Mount-RegistryHive -FilePath 'C:\Temp\NTUSER.DAT'
$hive = Mount-RegistryHive -FilePath 'C:\Temp\NTUSER.DAT' -Hive 'HKEY_USERS\TEMP'
$hive = Mount-RegistryHive -FilePath 'C:\Temp\NTUSER.DAT' -Hive 'HKEY_USERS\THING{0}'
The path to the hive file.
If the DefaultUser parameter is provided, then this parameter is discarded.
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Registry location where to mount the hive.
If {0}
is provided, a formatter will provide some randomness to the location.
If the DefaultUser parameter is provided, then this parameter is discarded.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: HKEY_USERS\TEMP{0}
Accept pipeline input: False
Accept wildcard characters: False
Optionally, provide just this switch to mount the Default User hive.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill DoNotAutoDismount Description }}
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
[Microsoft.Win32.RegistryKey]
{{ Fill in the Synopsis }}
Mount-RedstoneWim [-ImagePath] <FileInfo> [[-MountPath] <DirectoryInfo>] [-ImageIndex <Int32>]
[-DoNotAutoDismount] [-LogFileF <FileInfo>] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
Do not auto-dismount when PowerShell exits.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Image index to mount.
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Path to the WIM file.
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases: PSPath
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Full path for the DISM log with {0} formatter to inject "DISM".
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Path the WIM will be mounted.
Type: System.IO.DirectoryInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.IO.DirectoryInfo
Create a RedStone Class.
New-RedstoneRedstone [-WhatIf] [-Confirm] [<CommonParameters>]
New-RedstoneRedstone [-SettingsJson] <FileInfo> [-WhatIf] [-Confirm] [<CommonParameters>]
New-RedstoneRedstone [-Settings] <PSObject> [-WhatIf] [-Confirm] [<CommonParameters>]
New-RedstoneRedstone [-Publisher] <String> [-Product] <String> [-Version] <String> [-Action] <String> [-WhatIf]
[-Confirm] [<CommonParameters>]
Create a Redstone Class with an easy to use function.
PS C:> {{ Add example code here }}
{{ Add example description here }}
Path to the settings.json file.
Type: System.IO.FileInfo
Parameter Sets: SettingsJson
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Pre-existing settings variable.
Type: System.Management.Automation.PSObject
Parameter Sets: Settings
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Name of the publisher, like "Mozilla".
Type: System.String
Parameter Sets: ManuallyDefined
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Name of the product, like "Firefox ESR".
Type: System.String
Parameter Sets: ManuallyDefined
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Version of the product, like "108.0.1". This was deliberatly not cast as a [version] to allow handling of non-semantic versioning.
Type: System.String
Parameter Sets: ManuallyDefined
Aliases:
Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Action that is being taken. This is purely cosmetic and directly affects the log name. For Example: - Using the examples from the Publisher, Product, and Version parameters. - Set action to 'install'
The log file name will be: Mozilla Firefox ESR 108.0.1 Install.log
If you don't specify an action, the action will be taken from the name of the script your calling this function from.
Type: System.String
Parameter Sets: ManuallyDefined
Aliases:
Required: True
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
``System.Array with two Values:
` 1. Redstone. The Redstone class`
` 2. PSObject. The results of parsing the provided settings.json file. Null if parameters supplied.`
Allows access to the Redstone class without having to use Using Module Redstone
.
- Ref: https://stephanevg.github.io/powershell/class/module/DATA-How-To-Write-powershell-Modules-with-classes/
https://github.com/VertigoRay/PSRedstone/wiki/Functions#new-redstone
Create Scheduled Task that runs at logon for any user that logs on.
New-RedstoneScheduledTaskTriggerLogonRunAsUser [[-TaskName] <String>] [[-Description] <String>]
[-Path] <FileInfo> [[-Arguments] <String>] [-WorkingDirectory] <DirectoryInfo> [-WhatIf] [-Confirm]
[<CommonParameters>]
Create Scheduled Task that runs at logon for any user that logs on.
This uses the Schedule Service COM Obect because the ScheduledTasks
module doesn't allow you to set "all users".
For other, less specific sceduled tasks needs, just use the ScheduledTasks
module.
There's no reason to replace the work done on that module; this just makes this one thing a little easier.
PS C:> {{ Add example code here }}
{{ Add example description here }}
The name of the task. If this value is NULL, the task will be registered in the root task folder and the task name will be a GUID value created by the Task Scheduler service.
A task name cannot begin or end with a space character. The '.' character cannot be used to specify the current task folder and the '..' characters cannot be used to specify the parent task folder in the path.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Sets the description of the task.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Sets the path to an executable file.
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Sets the arguments associated with the command-line operation.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Sets the directory that contains either the executable file or the files that are used by the executable file.
Type: System.IO.DirectoryInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
-
Triggers Create:
-
TASK_TRIGGER_LOGON
(9): Triggers the task when a specific user logs on.
-
-
Actions Create:
-
TASK_ACTION_EXEC
(0): The action performs a command-line operation. For example, the action could run a script, launch an executable, or, if the name of a document is provided, find its associated application and launch the application with the document.-
ExecAction:
- Path: Sets the path to an executable file.
- Arguments: Sets the arguments associated with the command-line operation.
- WorkingDirectory: Sets the directory that contains either the executable file or the files that are used by the executable file.
-
ExecAction:
-
-
RegisterTaskDefinition:
TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD
(6)- Path: See TaskName parameter description.
- Definition: The definition of the registered task.
-
Flags: 6
-
TASK_CREATE
(0x2): The Task Scheduler service registers the task as a new task. -
TASK_UPDATE
(0x4): The Task Scheduler service registers the task as an updated version of an existing task. When a task with a registration trigger is updated, the task will execute after the update occurs.
-
- UserId: The user credentials used to register the task. If present, these credentials take priority over the credentials specified in the task definition object pointed to by the Definition parameter.
-
LogonType: Defines what logon technique is used to run the registered task.
-
TASK_LOGON_GROUP
(4): Group activation. The groupId field specifies the group.
-
{{ Fill in the Synopsis }}
New-RedstoneWim [-ImagePath] <FileInfo> [-CapturePath] <DirectoryInfo> [-Name] <String>
[[-LogFileF] <FileInfo>] [-WhatIf] [-Confirm] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill CapturePath Description }}
Type: System.IO.DirectoryInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill ImagePath Description }}
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill LogFileF Description }}
Type: System.IO.FileInfo
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Name Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
Run Set-ItemProperty
on a mounted registry hive.
Set-RedstoneRegistryHiveItemProperty [[-Hive] <RegistryKey>] [[-Key] <String>] [[-Value] <String>]
[[-Type] <String>] [[-Data] <Object>]
Run Set-ItemProperty
on a mounted registry hive.
This process is non-trivial as it requires us to close handles after creating keys and do garbage cleanup when we're done.
Doing these extra steps allows unloading/dismounting of the hive.
Return the resulting ItemProperty.
$result = Set-RegistryHiveItemProperty -Hive $hive -Key 'Policies\Microsoft\Windows\Personalization' -Value 'NoChangingSoundScheme' -Type 'String' -Data 1
Where $hive
was created with:
$hive = Mount-RegistryHive -DefaultUser
The key object returned from Mount-RegistryHive
.
Type: Microsoft.Win32.RegistryKey
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Key path, within the hive, to edit.
This will be concatinated with the hive.
A leading \\
will be stripped.
If the Hive
parameter is not provided, this should be the full Key.
Do NOT use PSDrive references like HKCU:
or HKLM:
.
Instead use normal registry paths, like HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the name of the property.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This is a dynamic parameter made available by the Registry provider. The Registry provider and this parameter are only available on Windows.
A registry type (aka RegistryValueKind) as expected when using Set-ItemProperty
.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specifies the value of the property.
Type: System.Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
[PSCustomObject]
Set-RedstoneRegsitryKeyPermissions [[-RootKey] <String>] [[-Key] <String>] [[-Sid] <SecurityIdentifier>]
[[-Recurse] <Boolean>] [[-RecurseLevel] <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
{{ Fill in the Description }}
PS C:> {{ Add example code here }}
{{ Add example description here }}
{{ Fill RootKey Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Key Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Sid Description }}
Type: System.Security.Principal.SecurityIdentifier
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill Recurse Description }}
Type: System.Boolean
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill RecurseLevel Description }}
Type: System.Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 5
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Void
Ref: https://stackoverflow.com/a/35843420/17552750
https://github.com/VertigoRay/PSRedstone/wiki/Functions#set-regsitrykeypermissions
Show-RedstoneToastNotification [-ToastNotifier] <String> [-ToastTitle] <String> [-ToastText] <String>
[<CommonParameters>]
{{ Fill in the Description }}
Show-ToastNotification @toastNotification
This displays a toast notification.
if ($ScheduleJob) { $jobTimespan = New-TimeSpan -Start ([datetime]::Now) -End $ScheduleJob }
if ($ScheduleReboot) { $rebootTimespan = New-TimeSpan -Start ([datetime]::Now) -End $ScheduleReboot }
$toastNotification = @{
ToastNotifier = 'Tech Solutions: Endpoint Solutions Engineering'
ToastTitle = 'Windows Update'
ToastText = 'This computer is overdue for {0} Windows Update{1} and the time threshold has exceeded.
{2} being forced on your system {3}.{4}' -f @(
$updateCount
$(if ($updateCount -gt 1) { 's' } else { $null })
$(if ($updateCount -eq 1) { 'Updates are' } else { 'The update is' })
$(if ($ScheduleJob) { 'on {0}' -f $ScheduleJob } else { 'now' })
$(if ($ScheduleReboot) { ' Reboot will occur on {0}.' -f $ScheduleReboot } else { $null })
)
}
Show-ToastNotification @toastNotification
{{ Fill ToastNotifier Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill ToastTitle Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
{{ Fill ToastText Description }}
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Kill a process and all of its child processes.
Stop-RedstoneProcessTree [-InputObject] <PSObject> [-Force] [<CommonParameters>]
Stop-RedstoneProcessTree [-Id] <Int32> [-Force] [<CommonParameters>]
Stop-RedstoneProcessTree [-Name] <String> [-Force] [<CommonParameters>]
Kill a process and all of its child processes. Returns any processes that failed to stop; returning nothing if everything stopped sucessfully.
$stillRunning = Get-Process 'overwolf' | Stop-ProcessTree -Force
$stillRunning = Stop-ProcessTree -Id 12345 -Force
$stillRunning = Stop-ProcessTree -Name 'overwolf' -Force
Provide a Process Object
Type: System.Management.Automation.PSObject
Parameter Sets: Process
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Provide a Process ID
Type: System.Int32
Parameter Sets: ProcessId
Aliases:
Required: True
Position: 1
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
Provide a Process Name
Type: System.String
Parameter Sets: ProcessName
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Force the Stop-Process
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
System.Diagnostics.Process