About the type of the parameter of the Powershell script in the Service Manager Authoring Tool
Hi friends,
In my previous post I’ve described in detail what type of the parameter SCSM2012 Authoring Tool automatically assigns for the Powershell script’s parameter if this parameter is GUID (in that post it was ID of Service Request). And I mentioned that we needed to control the script’s text in XML file. That is definitely awkward and one of my colleagues has prompted me how to avoid that.
If you use the Authoring Tool and GUID as a parameter in your Powershell script you can change a syntax of the script and avoid manual editing of the XML files. For instance, if we use R_GUID as a parameter of GUID type and have such a string in the script:
$reviewer = Get-SCSMObject -Id $R_GUID.ToString()
we can use another syntax with the same result:
$reviewer = Get-SCSMObject -Id ([guid]$R_GUID).ToString()
Compare these two variants
# source code
# The string below was automatically generated by the Authoring Tool and then we edited it manually
param ( [guid]$R_GUID )
# our source code
$reviewer=Get-SCSMObject-Id$R_GUID.ToString()
and
# final code
# The string below was automatically generated by the Authoring Tool
param ( [string]$R_GUID )
# our final code
$reviewer=Get-SCSMObject-Id ([guid]$R_GUID).ToString()
Comments (1)
Marat Kuanyshev
reply