- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2015 12:41 PM
We are working on Servicenow integration with Exchange server. When running a powershell script. we are getting below error
Has anyone faced this issue ?
*** Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.Stack Trace: at Microsoft.PowerShell.ConsoleHostUserInterface.HandleThrowOnReadAndPrompt()at Microsoft.PowerShell.ConsoleHostUserInterface.Prompt(String caption, String message, Collection`1 descriptions)at System.Management.Automation.Internal.Host.InternalHostUserInterface.Prompt(String caption, String message, Collection`1 descriptions)at Microsoft.PowerShell.Commands.ReadHostCommand.BeginProcessing()at System.Management.Automation.Cmdlet.DoBeginProcessing()at System.Management.Automation.CommandProcessorBase.DoBegin()
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2015 12:25 PM
You need to remove the Read-Host. To access your scratchpad variable, inside PowerShell, you identify it as:
$env:SNC_NetworkID
so your line above would be:
$sam = $env:SNC_NetworkID
Effectively, the scratchpad variable becomes an environment variable, hence the $env:
SNC_ identifies the scratchpad variable then you add the name of the variable you set in the PowerShell variables field on the Run PowerShell activity.
To make sure that your NetworkID variable has a value when it is passed, I would do something like this in your PowerShell script:
if(test-path env:\SNC_NetworkID){ #Notice this line does not have the "$" and includes a "\" - This is not a typo
$sam = $env:SNC_NetworkID #Notice this line includes the "$" and does NOT include the "\" - also not a typo
}
Then you could do an else{} if your NetworkID field was NULL.
Hope this helps,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2024 04:44 PM
Hi @chadlockwood ,
I have same error Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.
When I removed the Read-Host and replace with $env: I got another error
$dlName = Read-Host $distroName
$dlOwner = Read-Host $distroOwner
$dlMembers = Read-Host $distroMembers
to this
$dlName = $env:distroName
$dlOwner = $env:distroOwner
$dlMembers = $env:distroMembers
New error: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
I am passing the data below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2024 06:10 AM
Try adding "SNC_" to your environment variables:
$dlName = $env:SNC_distroName
$dlOwner = $env:SNC_distroOwner
$dlMembers = $env:SNC_distroMembers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 12:24 AM
Hi @chadlockwood ,
thanks, I'm able now to create DL, but I have problems adding multiple members. My current script will succeed only if for 1 member.
Do you have idea how to add multiple member to DL? My dlMembers is a list collector type that gets the email of user.
My current script is below:
$tenantID = $exchangeServer
$appID = $exchgUsername
$CertificateThumbPrint = $exchgPassword
## Connect to Exchange Online
Connect-ExchangeOnline -CertificateThumbPrint $CertificateThumbPrint `
-AppID $appID `
-Organization $tenantID
# Prompt for Distribution List details
$dlName = $distroName
$dlOwner = $distroOwner
$dlMembers = $distroMembers
New-DistributionGroup -Name $dlName -Alias $dlName -PrimarySmtpAddress "$($dlName)@yourdomain.com" -ManagedBy $dlOwner -Members $dlMembers -MemberDepartRestriction Closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 06:50 AM
Write out the value of $distroMembers with multiple values to make sure it is a comma-separated list of values. Coming from a list collector, it will probably look something like this:
"email1@yourdomain.com, email2@yourdomain.com,email3@yourdomain.com"
PowerShell through ServiceNow can be finicky sometimes, so to get the right values, you might try:
$dlMembers = $distroMembers.Split(",")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2017 12:05 AM
Hi my SNOW friends,
And what about the situation where there is no Read or Write-Host?
I got a problem with this line of code:
foreach($g in $groupMembership)
{
Remove-DistributionGroupMember -Identity $g.PrimarySmtpAddress -Member $distinguishedName -BypassSecurityGroupManagerCheck
}
Without this my code working fine do you know what should I do?