Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:27:18+00:00 2026-06-12T09:27:18+00:00

Take this code: $logged_on_user = get-wmiobject win32_computersystem | select username If I want to

  • 0

Take this code:

$logged_on_user = get-wmiobject win32_computersystem | select username

If I want to output the value into a new string I’d do something like:

$A = $logged_on_user.username

However, if I do the following:

$logged_on_user = get-wmiobject win32_computersystem | select *

..to try to assign all the values to a new “object”, do I?:

$logged_on_user.items
$logged_on_user.value
$logged_on_user.text
$logged_on_user.propertry

I’ve tried them all and they don’t work.

Anybody got any ideas?

Thanks

P.S. I think I may have got the title of this question wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:27:19+00:00Added an answer on June 12, 2026 at 9:27 am

    In your example:

    $logged_on_user = get-wmiobject win32_computersystem | select username
    

    creates a new PSCustomObject with a single property – username. When you do the following:

    $A = $logged_on_user.username
    

    you are assigning the return value of the PSCustomObject’s username property to a variable $A. Because the return type of the username property is a string, $A will also be a string.

    When executing the following:

    $cs = get-wmiobject win32_computersystem
    

    If you assign $cs to a new variable like in the following:

    $newVariable = $cs
    

    Then $newVariable will reference the same object $cs does, so all properties and methods that are accessible on $cs will also be accessible on $newVariable.

    If you don’t specify any properties or call any methods on an object when assigning a return value to another variable, then the return value is the object itself, not the return value of one of the object’s properties or methods.

    Additional info, but not directly related to the question:

    When you pipe the output of get-wmiobject to select-object, like in the following:

    $cs = get-wmiobject win32_computersystem | select-object *
    

    The variable $cs is of type: PSCustomObject as opposed to ManagementObject (as it is when you do not pipe to Select-Object) which has all of the same properties and their values that the ManagementObject that was piped in did.

    So, if you only want the property values contained by the ManagementObject, there is no need to pipe the output to Select-Object as this just creates a new object (of type PSCustomObject) with the values from the MangementObject. Select-Object is useful when you either want to select a subset of the properties of the object that is being piped in, or if you want to create a new PSCustomObject with different properties that are calculated through expressions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this code into consideration: Proxy p = new Proxy(Type.SOCKS, new InetSocketAddress(proxyURL, port)); try
Take a look at this code: public class Test { public static void main(String...
I have code like this: // Take the xml message and turn it into
Take this code snippet for example: window.location.href = 'mysite.htm#images'; Already being on the site
Take this code: $json = file_get_contents($this->url, true); $decode = json_decode($json, true); foreach ($decode as
Take this example code (ignore it being horribly inefficient for the moment) let listToString
take this simple code: class A{ public: virtual void foo() = 0; void x(){
take a look at this code: $(document).ready(function() { document.getElementById(sliderId).onmousedown = sliderMouseDown; }); function sliderMouseDown()
Take a look on this code, what I wrote: http://pastebin.com/TZpUAWpA , and this jQuery,
Please take a look at this code: template<class T> class A { class base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.