New-PSUScript
SYNOPSIS
Creates a new script within PowerShell Universal.
SYNTAX
ScriptBlock
New-PSUScript -ScriptBlock <ScriptBlock> [-ManualTime <Int32>] [-TimeOut <Double>] -Name <String>
[-Description <String>] [-Parameter <ScriptParameter[]>] [-Tag <Tag[]>] [-Status <ScriptStatus>]
[-Environment <String>] [-Notes <String>] [-DisableManualInvocation] [-Path <String>] [-MaxHistory <Int32>]
[-ConcurrentJobs <Int32>] [-Credential <Variable>] [-RetryLimit <Int32>] [-DiscardPipeline] [-LoadProfile]
[-WorkingDirectory <String>] [-Role <String[]>] [-PortalOutputType <PortalOutputType>]
[-AvailableInBranch <String[]>] [-PortalOpenInNewWindow] [-Icon <String>]
[-PortalBehavior <ScriptPortalBehavior>] [-PortalLeaveForm] [-DisplayOutputOnExecute]
[-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
[-Integrated] [-TrustCertificate] [-Cookies] [<CommonParameters>]Path
New-PSUScript [-ManualTime <Int32>] [-TimeOut <Double>] -Name <String> [-Description <String>]
[-Parameter <ScriptParameter[]>] [-Tag <Tag[]>] [-Status <ScriptStatus>] [-Environment <String>]
[-Notes <String>] [-DisableManualInvocation] -Path <String> [-MaxHistory <Int32>] [-ConcurrentJobs <Int32>]
[-Credential <Variable>] [-RetryLimit <Int32>] [-DiscardPipeline] [-LoadProfile] [-WorkingDirectory <String>]
[-Role <String[]>] [-PortalOutputType <PortalOutputType>] [-AvailableInBranch <String[]>]
[-PortalOpenInNewWindow] [-Icon <String>] [-PortalBehavior <ScriptPortalBehavior>] [-PortalLeaveForm]
[-DisplayOutputOnExecute] [-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>]
[-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
[<CommonParameters>]Module
DESCRIPTION
Creates a new script within PowerShell Universal. Scripts can be manually executed or scheduled inside PSU. Scripts created based on content will be written to the repository directory. Scripts created by path will be referenced by that path.
Script configurations are stored in .universal/scripts.ps1
You can also use this cmdlet to create scripts through the REST API.
EXAMPLES
Example 1
Creates a script within PSU that references a relative path of Script1.ps1 in the repository folder.
Example 2
Creates a script within PSU based on the script block provided. This will create a Script1.ps1 file within the repository directory.
PARAMETERS
-AppToken
The AppToken that is used for calling the PowerShell Universal Management API. You can also call Connect-PSUServer before calling this cmdlet to set the AppToken for the entire session.
-ComputerName
Specifies the computer name or URL that should be called when accessing the PowerShell Universal Management API. You can also use Connect-PSUServer before calling this cmdlet to set the computer name for the entire session.
-Description
The description of the script.
-DisableManualInvocation
Disables manual invocation of the script. The script can only be run on a schedule.
-ManualTime
The amount of time it would take to run this particular script manually.
-MaxHistory
The maximum job history for this script. This defaults to 100.
-Name
The name of this script.
-Notes
Notes to include with this script.
-Parameter
Obsolete
-Path
The path to the script. This can be a relative path to the repository directory or an absolute path.
-ScriptBlock
A script block to define for this script.
-Status
Not used.
-Tag
Tags to assign to this script.
-ConcurrentJobs
The number of concurrent jobs that are allowed for this script. By default, there is no limit.
-Environment
The environment to run this script within.
-TimeOut
The number of minutes before jobs based on this script will time out.
-Credential
The user credential variable to use when executing this script.
-UseDefaultCredentials
Use default credentials when connecting to the management API
-Integrated
Executes the command internally rather than using the Management API. Only works when running script from within PowerShell Universal.
-RetryLimit
The number of times to retry this script if it fails.
-DiscardPipeline
Whether to discard pipeline output rather than persist it in the database.
-LoadProfile
Loads the user profile when running this script as another user.
-WorkingDirectory
The working directory of the script.
-Command
The command that defines this script.
-Module
The module that contains the command that defines this script.
-Role
The role that is required to execute this script.
-AvailableInBranch
When specified, this script will only be available in the specified branches.
-PortalOutputType
The type of portal output to display when running this script in the portal.
-TrustCertificate
Whether the cmdlet should ignore certificate issues.
-PortalOpenInNewWindow
Whether to open this script in a new window when viewing it in the portal.
-Icon
An icon to display in the portal.
-DisplayOutputOnExecute
Displays output of the script while it is executing in the portal.
-PortalBehavior
How this script behaves in the portal.
-PortalLeaveForm
Whether to leave the script's form after executing it in the portal.
-Cookies
Reuses and persists authentication cookies for the current PowerShell session.
-ExecutionRole
Specifies one or more roles that can execute the resource.
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see about_CommonParameters.
INPUTS
None
OUTPUTS
System.Object
NOTES
RELATED LINKS
PERMISSIONS
The access token requires automation.scripts.<script path>/create to run this cmdlet remotely.
Last updated
Was this helpful?