Cannot bind argument to parameter 'ResourceId' because it is null

Gummadavelly, Chaitanya Kumar 0 Reputation points
2023-01-27T00:28:25.5633333+00:00

I'm trying to add device to a collection in SCCM from ServiceNow MID Server, But I'm getting the error with Get-CM Device not returning the value and giving the error message "Cannot bind argument to parameter 'ResourceId' because it is null". When I run the same script in SCCM Machine it's running fine but when I'm running from my MID Server it's giving the error.

Here is the script:

$device= 'A311688'
$collection= 'SCM-SNOW-TEST' 
$coll = (Get-CMCollection -name $collection).CollectionID ;
$coll
   $id = (Get-CMDevice  -name $device).ResourceID;
$id
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,463 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,332 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,126 Reputation points
    2023-02-01T11:20:00.8566667+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query.

    The error message "Cannot bind argument to parameter 'ResourceId' because it is null" suggests that the script is trying to pass a null value to the 'ResourceId' parameter when running the Get-CMDevice cmdlet. This error occurs when the script is unable to find the device in the SCCM database that it is trying to add to the collection.

    The issue could be caused due to a few reasons:

    -The MID server does not have access to the SCCM environment. Make sure that the MID Server has access to the SCCM server and the necessary permissions to run the script.

    -The device is not yet discovered by the SCCM environment. Make sure that the device is discovered by the SCCM environment before running the script.

    -The resource name is not correct. Make sure that the resource name passed to the script is correct.

    -The Cmdlet is not available on the MID server. Make sure that the SCCM client is installed on the MID server.

    You can try the following steps to troubleshoot the issue:

    1. Verify that the MID Server has access to the SCCM server and that it has the necessary permissions to run the script.
    2. Check if the device is discovered by the SCCM environment.
    3. Verify that the resource name passed to the script is correct.
    4. Verify that the SCCM client is installed on the MID server.
    5. Try running the script on the SCCM machine to see if it runs without error.
    6. Check the logs on the SCCM server and MID server to see if there are any error messages or issues that may indicate the cause of the problem.

    It's also worth checking the script and the parameters being passed, make sure that the script is passing the correct parameters and that the parameter is not null or empty.

    If the script is running fine on the SCCM machine but not on the MID Server, it could be an issue with the environment. It's a good idea to check the SCCM and MID Server logs for more information about the error.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

  2. Limitless Technology 44,126 Reputation points
    2023-02-01T11:20:22.12+00:00

    Double post

    0 comments No comments