Skip to main content

Get started

Add a new PSScriptInfo#

To 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 -FilePath C:\Script\File.ps1 -Properties @{
Version = ""
DateCreated = "2021-03-30"

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 block#

To 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.

Get-PSScriptInfo -FilePath C:\Script\File.ps1
Version :
DateCreated : 2021-03-30

Remove a PSScriptInfo block#

To 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)

Remove-PSScriptInfo -FilePath C:\Script\File.ps1

Update a PSScriptInfo block#

To 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

"Version" : "",
"GUID" : "a3002a7c-0870-4b5f-8bed-cd31f7f23432",
"DateCreated" : "2021-03-29",
"DateUpdated" : "2021-03-30",
"ProjectSite" : ""
function foo {

The following example will remove the key guid

Update-PSScriptInfo -FilePath C:\Script\file.ps1 -Properties @{
guid = $null

To add a new key simple add the key in the hashtable

Update-PSScriptInfo -FilePath C:\Script\file.ps1 -Properties @{
LicenseURL = ''

To update an existing value, specify the key with the same name and the new value

Update-PSScriptInfo -FilePath C:\Script\file.ps1 -Properties @{
Version = ''
DateUpdated = (get-date)