PowerShell script execution failed. Script returned status 1 using account user

snow34
Tera Contributor

PowerShell script execution failed. Script returned status 1 using account user 

 

can anyone help me that how to resolve this issue?

 

 

12 REPLIES 12

WA1
Kilo Sage

Hello @snow34 , 

Did you find a solution for this error message please ? I'm having the same error also.. 

Thank you 

Amit Verma
Kilo Patron
Kilo Patron

Hi @snow34 

 

Are you passing any credentials in your script ? Also, from where you are running this script, from a workflow or a flow or via ecc queue ? Is your script intended to run on mid server ?

 

If possible, could you please share the script.

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

I am running this from flow designer. below is the script for your reference.

 

Param([string]$collection, [string]$device)

# Import SCCM module
Import-Module "$executingScriptDirectory\SCCMSpoke\SCCMMain" -DisableNameChecking

# Copy the environment variables to their parameters
if (test-path env:\SNC_collection) {
$collection = $env:SNC_collection
$device = $env:SNC_device
}

SNCLog-ParameterInfo @("Running RemoveFromDeviceCollection", $collection, $device)

function Remove-FromDeviceCollection() {
Import-Module -Name "$(split-path $Env:SMS_ADMIN_UI_PATH)\ConfigurationManager.psd1"
Set-Location -path "$(Get-PSDrive -PSProvider CMSite):\"

$collection = $args[0];
$device = $args[1];

$id = (Get-CMDevice -Name $device).ResourceID
Remove-CMDeviceCollectionDirectMembershipRule -CollectionName $collection -ResourceId $id -force
}

try {
$session = Create-PSSession -sccmServerName $computer -credential $cred

SNCLog-DebugInfo "`tInvoking Invoke-Command -ScriptBlock `$'{function:Remove-FromDeviceCollection}' -ArgumentList $collection, $device"

if(($collection -eq $null) -or ($collection -eq "")) {
Write-Host "Empty collection name"
} elseif(($device -eq $null) -or ($device -eq "")) {
Write-Host "Empty device name"
} else {
Invoke-Command -Session $session -ScriptBlock ${function:Remove-FromDeviceCollection} -ArgumentList $collection, $device
}
} catch {
Write-Host $error
}finally {
if($session -ne $null) {
Remove-PSSession -session $session
}
}

J Siva
Tera Sage

Hi All,

Was anyone able to fix this issue ?

I'm trying to configure MS exchange server spoke.

I'm getting the same error. If anyone had successfully configured exchange server integration using spoke, please let me know.

Thanks,

Siva

Shidhi
Tera Contributor

Hi @J Siva,

Are you able to fix the issue. Could you please share the steps.

 

Thank you!