I have a powershell runbook in Azure Automation with the following code:
param
(
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
[String] $ADMINUSERS,
)
#parse User data
function Get-GroupUser
{
[CmdletBinding()]
Param
(
[Parameter()]
[string]$inputUsers
)
$userlist = $Local:inputUsers.split(',')
if ($Local:inputUsers -notlike "*@*") {
$userlist.replace(' ','')
}
else {
$returnArray = @()
foreach ($user in $($inputUsers | convertFrom-Json)) {
$returnArray += $user.split('@')[0]
}
$returnArray
}
Get-GroupUser -inputUsers $ADMINUSERS
My first input for $ADMINUSERS look like this:
["johndoe@abc.biz","janedoe@abc.biz"]
When the runbook run, it fails immediately with the following error:
Cannot process argument transformation on parameter 'ADMINUSERS'. Cannot convert value to type System.String. (Cannot convert value to type System.String. (Cannot convert value to type System.String.))
My second input for $ADMINUSERS look like this:
johndoe,janedoe
And this completes successfully.
Any ideas how I can fix the first input error on my runbook in Azure Automation?
NOTE: When I run both input locally from a server, it completes successfully.