Querying SCCM only works sometimes Powershell The Next CEO of Stack OverflowHow does database indexing work?How to return only the Date from a SQL Server DateTime datatypeInserting multiple rows in a single SQL query?Determine installed PowerShell versionget-wmiobject sql join in powershell - trying to find physical memory vs. virtual memory of remote systemsPowerShell says “execution of scripts is disabled on this system.”How do you comment out code in PowerShell?PowerShell Convert output to hashtable array (data type conversion)Get Username from computer name using powershell and sccmSCCM and Client 'Replace'

Free fall ellipse or parabola?

How seriously should I take size and weight limits of hand luggage?

What happens if you break a law in another country outside of that country?

Is a linearly independent set whose span is dense a Schauder basis?

How can I prove that a state of equilibrium is unstable?

Planeswalker Ability and Death Timing

Is this a new Fibonacci Identity?

Can you teleport closer to a creature you are Frightened of?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

How to show a landlord what we have in savings?

Which acid/base does a strong base/acid react when added to a buffer solution?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Is it possible to create a QR code using text?

Calculating discount not working

Masking layers by a vector polygon layer in QGIS

A hang glider, sudden unexpected lift to 25,000 feet altitude, what could do this?

Why did early computer designers eschew integers?

Why did the Drakh emissary look so blurred in S04:E11 "Lines of Communication"?

pgfplots: How to draw a tangent graph below two others?

Find a path from s to t using as few red nodes as possible

That's an odd coin - I wonder why

Arrows in tikz Markov chain diagram overlap

Find the majority element, which appears more than half the time



Querying SCCM only works sometimes Powershell



The Next CEO of Stack OverflowHow does database indexing work?How to return only the Date from a SQL Server DateTime datatypeInserting multiple rows in a single SQL query?Determine installed PowerShell versionget-wmiobject sql join in powershell - trying to find physical memory vs. virtual memory of remote systemsPowerShell says “execution of scripts is disabled on this system.”How do you comment out code in PowerShell?PowerShell Convert output to hashtable array (data type conversion)Get Username from computer name using powershell and sccmSCCM and Client 'Replace'










0















I wish to query the SCCM SQL server but it only works when the command is a certain way. For instance, this works



Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system"


But this will not work



(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system").Name


When I run the first command, the output looks like this for every system



__GENUS : 2
__CLASS : SMS_R_System
__SUPERCLASS : SMS_Resource
__DYNASTY : SMS_BaseClass
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : SMS_Resource, SMS_BaseClass
__SERVER : serverName
__NAMESPACE : rootsmssite_P01
__PATH :
Name : computerName
PSComputerName : serverName


I tried surrounding the command with parenthesis in the non-working example and doing .Name to retrieve the "Name" attribute but that didn't work. There was no error but the script just kept running with no output.



Why is this the case? I'm able to run a command like this without a problem:



$Computers =(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system where LastLogonUserName='$User'").Name









share|improve this question






















  • What version of PowerShell?

    – TheIncorrigible1
    Mar 8 at 19:31











  • @TheIncorrigible1 5.1

    – Colebacha2
    Mar 8 at 19:33











  • Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

    – TheIncorrigible1
    Mar 8 at 19:41











  • @TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

    – Colebacha2
    Mar 8 at 19:45











  • Are you able to access the name on it then? $output['Name']

    – TheIncorrigible1
    Mar 8 at 19:47















0















I wish to query the SCCM SQL server but it only works when the command is a certain way. For instance, this works



Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system"


But this will not work



(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system").Name


When I run the first command, the output looks like this for every system



__GENUS : 2
__CLASS : SMS_R_System
__SUPERCLASS : SMS_Resource
__DYNASTY : SMS_BaseClass
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : SMS_Resource, SMS_BaseClass
__SERVER : serverName
__NAMESPACE : rootsmssite_P01
__PATH :
Name : computerName
PSComputerName : serverName


I tried surrounding the command with parenthesis in the non-working example and doing .Name to retrieve the "Name" attribute but that didn't work. There was no error but the script just kept running with no output.



Why is this the case? I'm able to run a command like this without a problem:



$Computers =(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system where LastLogonUserName='$User'").Name









share|improve this question






















  • What version of PowerShell?

    – TheIncorrigible1
    Mar 8 at 19:31











  • @TheIncorrigible1 5.1

    – Colebacha2
    Mar 8 at 19:33











  • Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

    – TheIncorrigible1
    Mar 8 at 19:41











  • @TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

    – Colebacha2
    Mar 8 at 19:45











  • Are you able to access the name on it then? $output['Name']

    – TheIncorrigible1
    Mar 8 at 19:47













0












0








0








I wish to query the SCCM SQL server but it only works when the command is a certain way. For instance, this works



Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system"


But this will not work



(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system").Name


When I run the first command, the output looks like this for every system



__GENUS : 2
__CLASS : SMS_R_System
__SUPERCLASS : SMS_Resource
__DYNASTY : SMS_BaseClass
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : SMS_Resource, SMS_BaseClass
__SERVER : serverName
__NAMESPACE : rootsmssite_P01
__PATH :
Name : computerName
PSComputerName : serverName


I tried surrounding the command with parenthesis in the non-working example and doing .Name to retrieve the "Name" attribute but that didn't work. There was no error but the script just kept running with no output.



Why is this the case? I'm able to run a command like this without a problem:



$Computers =(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system where LastLogonUserName='$User'").Name









share|improve this question














I wish to query the SCCM SQL server but it only works when the command is a certain way. For instance, this works



Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system"


But this will not work



(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system").Name


When I run the first command, the output looks like this for every system



__GENUS : 2
__CLASS : SMS_R_System
__SUPERCLASS : SMS_Resource
__DYNASTY : SMS_BaseClass
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : SMS_Resource, SMS_BaseClass
__SERVER : serverName
__NAMESPACE : rootsmssite_P01
__PATH :
Name : computerName
PSComputerName : serverName


I tried surrounding the command with parenthesis in the non-working example and doing .Name to retrieve the "Name" attribute but that didn't work. There was no error but the script just kept running with no output.



Why is this the case? I'm able to run a command like this without a problem:



$Computers =(Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system where LastLogonUserName='$User'").Name






sql powershell sccm






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 8 at 19:27









Colebacha2Colebacha2

34




34












  • What version of PowerShell?

    – TheIncorrigible1
    Mar 8 at 19:31











  • @TheIncorrigible1 5.1

    – Colebacha2
    Mar 8 at 19:33











  • Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

    – TheIncorrigible1
    Mar 8 at 19:41











  • @TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

    – Colebacha2
    Mar 8 at 19:45











  • Are you able to access the name on it then? $output['Name']

    – TheIncorrigible1
    Mar 8 at 19:47

















  • What version of PowerShell?

    – TheIncorrigible1
    Mar 8 at 19:31











  • @TheIncorrigible1 5.1

    – Colebacha2
    Mar 8 at 19:33











  • Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

    – TheIncorrigible1
    Mar 8 at 19:41











  • @TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

    – Colebacha2
    Mar 8 at 19:45











  • Are you able to access the name on it then? $output['Name']

    – TheIncorrigible1
    Mar 8 at 19:47
















What version of PowerShell?

– TheIncorrigible1
Mar 8 at 19:31





What version of PowerShell?

– TheIncorrigible1
Mar 8 at 19:31













@TheIncorrigible1 5.1

– Colebacha2
Mar 8 at 19:33





@TheIncorrigible1 5.1

– Colebacha2
Mar 8 at 19:33













Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

– TheIncorrigible1
Mar 8 at 19:41





Instead of forming your own query, have you considered using the cmdlet's parameters? Get-WmiObject -Namespace $SCCMNameSpace -ComputerName $SCCMServer -Class SMS_R_SYSTEM -Property Name

– TheIncorrigible1
Mar 8 at 19:41













@TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

– Colebacha2
Mar 8 at 19:45





@TheIncorrigible1 I had not considered that; however, that is yielding the exact same output instead of just the name.

– Colebacha2
Mar 8 at 19:45













Are you able to access the name on it then? $output['Name']

– TheIncorrigible1
Mar 8 at 19:47





Are you able to access the name on it then? $output['Name']

– TheIncorrigible1
Mar 8 at 19:47












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069765%2fquerying-sccm-only-works-sometimes-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55069765%2fquerying-sccm-only-works-sometimes-powershell%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme