- 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-06-2017 07:27 AM
Artur,
What error message are you getting from this? Have you tried printing out $g.PrimarySmtpAddress to make sure it is the correct data? What is the rest of the code doing?
By the way, you can still use Write-Host. it will print to the MID server log in \agent\logs. Write-Verbose will also print there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2017 02:39 AM
Well I figure out what was wrong
I add just -confirm $false and it is work
But anyway thanks for your time