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 9197071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:59:31+00:00 2026-06-17T21:59:31+00:00

Here is my code: function Get-OSInfo { param([string]$Computer) $OS = gwmi -class Win32_OperatingSystem -computer

  • 0

Here is my code:

function Get-OSInfo {
    param([string]$Computer)
    $OS = gwmi -class Win32_OperatingSystem -computer $Computer
    $OS | Add-Member –MemberType NoteProperty –Name OSType –Value ""
    $OS.OSType = Get-OSType -Input $OS
    write $OS
}

function Get-OSType {
    param([?]$Input)
    if ($Input.ProductType -eq 1) {
        write "Client OS"
    }
}

$blah = Get-OSInfo -Computer mypc
$blah | fl *

I realize that this could be done with a single function (or in the body of the script itself), but I have simplified the functions to highlight the trouble I’m having. What I want to do is pass the gwmi dataset from the Get-OSInfo function as a parameter variable in the Get-OSType so I can reference all of its properties in the second function without passing them individually from the first. Clear as mud?

I have tried multiple parameter accelerator types, [ref], [array], [object[]], etc., but I haven’t found anything that works as a parameter. The only thing that has proven to work is to change the second function to use args[0] for accepting input, but that is not as clean as using parameters, and since it works, I can’t help but think there is a parameter that should work as well.

  • 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-17T21:59:32+00:00Added an answer on June 17, 2026 at 9:59 pm

    Avoid using $input as that has special meaning in functions (representing pipeline input). Just rename the parameter to something like $OS.

    The docs (man about_automatic_variables) on $input say:

    Contains an enumerator that enumerates all input that is
    passed to a function. The $input variable is available only to
    functions and script blocks (which are unnamed functions). In the
    Process block of a function, the $input variable enumerates the
    object that is currently in the pipeline. When the Process block
    completes, there are no objects left in the pipeline, so the $input
    variable enumerates an empty collection. If the function does not
    have a Process block, then in the End block, the $input variable
    enumerates the collection of all input to the function.

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

Sidebar

Related Questions

Here is my jQuery code: $.get('/Home/GetList', function(data) { debugger; $('#myMultiSelect').val(data); }); Here is my
So here's my code: function csq($string) { $search = array(chr(145), chr(146), chr(147), chr(148), chr(151),
Here is my code: function init(){ $.get(URL, function(data) { DATA = data; var srcWithHead
I have a function that get the key code when pressed. Here is my
I have the following javascript code: $.get(categories/json_get_cities/ + stateId, function(result) { //code here },
Here the code from my function: -- Get Country Names DECLARE getCountriesName CURSOR FOR
Working on an AJAX class. Here is the code: function AjaxRequest(params) { if (params)
my sample code is here include 'simple_html_dom.php'; function get_all_links($url){ global $host; $html = new
Here is the code: $('#sousmenu a').click (function (){ startSlideshow(<?php echo json_encode(glob(photos- .$_GET[folder]. /*.jpg));?>); return
Here is my code: function pauseSound() { var pauseSound = document.getElementById(backgroundMusic); pauseSound.pause(); } I

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.