Get started
#
Add a new PSScriptInfoTo add a new PSScriptInfo block to a file that does not already have a PSScriptInfo block use the Add-PSScriptInfo
cmdlet. The cmdlet takes two parameters, filepath that defines the file that you want to add a PSScriptInfo block to and Properties. Properties should be a hashtable where each key will be a root item in the PSScriptInfo block.
Add-PSScriptInfo will throw if there is a existing PSScriptInfo in the file specified. Either specify -force
to overwrite the existing PSScriptInfo block or use Update-PSScriptInfo
to modify an existing PSScriptInfo block.
#
Get a PSScriptInfo blockTo read the PSScriptInfo block from a file use the Get-PSScriptInfo
cmdlet. This will read the PSScriptInfo block and return a PSCustomObject with all configured properties.
#
Remove a PSScriptInfo blockTo remove a PSScriptBlock completly use the Remove-PSScriptInfo
cmdlet. This cmdlet will remove the whole PSScriptInfo block. (Use Update-PSScriptInfo
to remove individual properties from a PSScriptInfo)
#
Update a PSScriptInfo blockTo update a PSScriptInfo block within a file use the Update-PSScriptInfo
cmdlet. The cmdlet has two parameters, filepath and properties. The properties parameter expects a hashtable. Keys that does is not present in the existing PSScriptInfo will be added, keys that already exist will be updated with the specified value except if the value is set to $null, then the property will be removed.
Assuming the file C:\Script\file.ps1 has the following content
The following example will remove the key guid
To add a new key simple add the key in the hashtable
To update an existing value, specify the key with the same name and the new value