- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 05:30 AM
I am trying to run a powershell script through run powershell activity. i am using 2 powershell run activity in my workflow first one is working fine but the second one is not executing and giving some error. but when i am executing it on my mid server powershell then its working
P.S. - I have already checked the ecc queue and copied the script path to my mid-powershell its working there but not through run activity.
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2015 04:44 AM
Actually the issue was with mid server account which was set to run locally. i changed it to Administrator now the script is working fine. the previous does not require any admin related jobs so that was running fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 06:55 AM
Can you please give us more details about what you are trying to run and what happens?
Can you give us:
- The Powershell script thats working
- The powershell script thats failing
- The error message your getting on the mid server logs
- Any other relevant information
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2015 11:36 PM
########################CONTENT OF RUN POWERSHELL##############################################
E:\STC\SCRIPTS\USER_ACCOUNT_MANAGEMENT\AddPST_Outlook.ps1 ${workflow.scratchpad.hostname} ${workflow.scratchpad.username} ${workflow.scratchpad.pst}
######################################END##########################################################
###################SCRIPT WHICH IS NOT WORKING IN RUN ACTIVITY#####################################
$ComputerName=$args[0]
$user=$args[1]
$name=$args[2]
$username="STC\Administrator"
$pw = "pass@word1"
$securepw = ConvertTo-SecureString $pw -asplaintext -force
$cred = new-object -typename System.Management.Automation.PSCredential -argument $username, $securepw
IF (!(TEST-PATH \\$ComputerName\C$\NewShare)) {NEW-ITEM \\$ComputerName\C$\NewShare -type Directory}
write-host "Folder Created"
$share = Get-WmiObject Win32_Share -List -ComputerName $ComputerName
$x=$share.create("C:\NewShare","NewShare",0)
#write-host "Share Folder Created"
Copy-Item -Path E:\STC\SCRIPTS\USER_ACCOUNT_MANAGEMENT\Client_PSTcreation.ps1 -Destination "\\$ComputerName\c$\NewShare\"
$RETDESC="File Transfer Success"
$str="`"<body><RETDESC>$RETDESC</RETDESC></body>`""
$str
#write-host "Entering into the Client Session"
Enter-PSSession -ComputerName $ComputerName -Credential $Cred
invoke-command -computername $ComputerName -filepath "\\$ComputerName\NewShare\Client_PSTcreation.ps1" -Argumentlist $ComputerName,$user,$name
Remove-Item -path "\\$ComputerName\c$\NewShare\Client_PSTcreation.ps1" -Force -Recurse
#Write-host "Files Deleted Successfully"
Exit-PSSession
###################################################END##############################################
#########################################ERROR SHOW IN ECC QUEUE###############################
<?xml version="1.0" encoding="UTF-8"?><results probe_time="10842"><result><error/>
<output>
Folder Created
</output>
<error>New-Item : Access to the path 'NewShare' is denied.At E:\STC\SCRIPTS\USER_ACCOUNT_MANAGEMENT\AddPST_Outlook.ps1:17 char:56+ IF (!(TEST-PATH \\$ComputerName\C$\NewShare)) {NEW-ITEM <<<< \\$ComputerName\C$\NewShare -type Directory}+ CategoryInfo : PermissionDenied: (\\WIN7\C$\NewShare:String) [New-Item], UnauthorizedAccessException+ FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommandGet-WmiObject : Could not get objects from namespace root\cimv2. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))At E:\STC\SCRIPTS\USER_ACCOUNT_MANAGEMENT\AddPST_Outlook.ps1:21 char:23+ $share = Get-WmiObject <<<< Win32_Share -List -ComputerName $ComputerName+ CategoryInfo : ObjectNotFound: (:) [Get-WmiObject], UnauthorizedAccessException+ FullyQualifiedErrorId : INVALID_NAMESPACE_IDENTIFIER,Microsoft.PowerShell.Commands.GetWmiObjectCommandYou cannot call a method on a null-valued expression.Stack Trace: at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)at System.Management.Automation.AssignmentStatementNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)</error></result><parameters><parameter name="queue" value="output"/><parameter name="from_sys_id" value=""/><parameter name="aka" value="10.53.223.44"/><parameter name="state" value="ready"/><parameter name="sys_created_on" value="2015-05-20 06:44:48"/><parameter name="debug" value="true"/><parameter name="probe" value="ca9edfec0a0a0baa011fe82922346887"/><parameter name="skip_sensor" value="true"/><parameter name="ecc_queue" value="ad6c05c70f880a00f3df6519b1050e81"/><parameter name="name" value="Windows - Powershell (nodes: 3)"/><parameter name="table_name" value="ecc_queue"/><parameter name="agent_correlator" value="rba.632c05c70f880a00f3df6519b1050e9b"/><parameter name="topic" value="Powershell"/><parameter name="error" value=""/><parameter name="probe_name" value="Windows - Powershell"/><parameter name="sys_id" value="ad6c05c70f880a00f3df6519b1050e81"/><parameter name="from_host" value=""/><parameter name="agent" value="mid.server.STC- Backup"/><parameter name="workflow" value="2d6c05c70f880a00f3df6519b1050e81"/><parameter name="processed" value=""/><parameter name="response_to" value=""/><parameter name="source" value="localhost"/><parameter name="sequence" value="14d701141a00000001"/><parameter name="script.ps1" value="E:\STC\SCRIPTS\USER_ACCOUNT_MANAGEMENT\AddPST_Outlook.ps1 WIN7 user2 user2_05.20.2015"/></parameters></results>
#
####################################################################################################
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2015 04:44 AM
Actually the issue was with mid server account which was set to run locally. i changed it to Administrator now the script is working fine. the previous does not require any admin related jobs so that was running fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2015 02:38 PM
Can you please elaborate what you mean by "the issue was with mid server account which was set to run locally"?
Do you mean you had it set to a local user on the MID server?