On 7/30/2020 at 9:57 PM, Dominique said:
How will i limit this script to run on the device VRPSCCMRS01?
How will i limit this script to run on the group IT Ops Systems Management Group > Production > SCCM Servers?
Just getting back from vacation, so let me know if what questions are still pending.
I assume you will be running this script as a propertysource? If so, then all you need to do is set the AppliesTo either to that one device or to that one group. You can use the AppliesTo wizard to help set that.
Instead of just writing the result to screen, I'd write it out as a property so that each device that has been changed will have a message in a custom property (ip2dns.renamed for example) detailing the result of the run.
You don't need to do an API call to get the device ID nor to get the address/name. Use tokens. You can simply set a variable (e.g. $hostname) to ##HOSTNAME##. When the collector runs the posh, it will replace those tokens where available. So, ##SYSTEM.HOSTNAME## would be replaced with the 10.6.195.211 and ##SYSTEM.DISPLAYNAME## would get replaced with VRPSCCMRS01. You can get the device id as well, using ##SYSTEM.DEVICEID##.
You can also store the script credentials as properties, so they're not hard coded into the script. So it would become something like this:
# Initialize Variables
<# account info #>
$accessId = ##ip2dns.accessid##
$accessKey = ##ip2dns.accesskey##
$company = ##ip2dns.company##
I like to have a specific API token for each LogicModule that uses the API. It makes it really easy to track down the cause of a problem when something goes awry.
I would say that definitely looks like an authentication failure.