Create Pull Request
| Date | Scan | Status | Result |
|---|---|---|---|
| 2025-07-12 23:44 | #41 | cancelled |
Biased
|
| 2025-07-12 00:58 | #8 | cancelled |
Clean
|
| 2025-07-10 05:06 | #7 | processing |
Clean
|
| 2025-07-09 23:22 | #6 | cancelled |
Clean
|
Import-DscResource -ModuleName "<ModuleName>" -ModuleVersion "<version>"
$contosoConnection = Get-AutomationConnection -Name 'ContosoConnection' $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $contosoConnection.UserName, $contosoConnection.Password Connect-Contoso -Credential $cred }
$globalNum = 0
function Set-GlobalNum {
param(
[int] $num
)
$globalNum = $num
}
function Get-GlobalNumTimesTwo {
$output = $globalNum * 2
$output
}
<#
.SYNOPSIS
Gets a Contoso User account
#>
function Get-ContosoUser {
[CmdletBinding](DefaultParameterSetName='UseConnectionObject', `
HelpUri='https://www.contoso.com/docs/information')]
[OutputType([String])]
param(
[Parameter(ParameterSetName='UserAccount', Mandatory=true)]
[ValidateNotNullOrEmpty()]
[string]
$UserName,
[Parameter(ParameterSetName='UserAccount', Mandatory=true)]
[ValidateNotNullOrEmpty()]
[string]
$Password,
[Parameter(ParameterSetName='ConnectionObject', Mandatory=true)]
[ValidateNotNullOrEmpty()]
[Hashtable]
$Connection
)
switch ($PSCmdlet.ParameterSetName) {
"UserAccount" {
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $UserName, $Password
Connect-Contoso -Credential $cred
}
"ConnectionObject" {
Connect-Contoso -Connection $Connection
}
}
}
$contosoConnection = Get-AutomationConnection -Name 'ContosoConnection' Connect-Contoso -Connection $contosoConnection }
function Get-ContosoUser {
[OutputType([String])]
param(
[string]
$Parameter1
)
# <script location here>
}
You can also use the same cmdlet to import a module from the PowerShell Gallery directly. Make sure to grab `ModuleName` and `ModuleVersion` from the [PowerShell Gallery](https://www.powershellgallery.com).
### Import modules from the PowerShell Gallery You can import [PowerShell Gallery](https://www.powershellgallery.com) modules either directly from the Gallery or from your Automation account. To import a module directly from the PowerShell Gallery: 1. Go to [https://www.powershellgallery.com](https://www.powershellgallery.com) and search for the module to import. 2. Under **Installation Options**, on the **Azure Automation** tab, select **Deploy to Azure Automation**. This action opens the Azure portal. 3. On the Import page, select your Automation account, and select **OK**.  To import a PowerShell Gallery module directly from your Automation account: 1. In the portal, search for and select **Automation Accounts**. 1. On the **Automation Accounts** page, select your Automation account from the list. 1. Under **Shared Resources**, select **Modules**. 1. Select **Browse gallery**, and then search the Gallery for a module. 1. Select the module to import, and select **Import**. 1. Select **OK** to start the import process.  ## Delete modules If you have problems with a module, or you need to roll back to a previous version of a module, you can delete it from your Automation account. You can't delete the original versions of the [default modules](#default-modules) that are imported when you create an Automation account. If the module to delete is a newer version of one of the [default modules](#default-modules), it rolls back to the version that was installed with your Automation account. Otherwise, any module you delete from your Automation account is removed. ### Delete modules in the Azure portal To remove a module in the Azure portal: 1. In the portal, search for and select **Automation Accounts**. 1. On the **Automation Accounts** page, select your Automation account from the list. 1. Under **Shared Resources**, select **Modules**. 1. Select the module you want to remove. 1. On the Module page, select **Delete**. If this module is one of the [default modules](#default-modules), it rolls back to the version that existed when the Automation account was created. ### Delete modules by using PowerShell To remove a module through PowerShell, run the following command: