Possible parameter values

Welcome Forums General PowerShell Q&A Possible parameter values

This topic contains 11 replies, has 5 voices, and was last updated by

 
Participant
10 months ago.

  • Author
    Posts
  • #90353

    Participant
    Points: 0
    Rank: Member

    Hello
    I just started learning PS
    One issue is bothering. For example:
    we have a comment like: Get-ItemPropertyValue
    and it has Required parameter Name. I found an example that we can you it like

    -Name LastWriteTime,CreationTime,Root

    and here is my question. How can I find a list of possible options to by use for "Name" parameter

    Thanks in advance for help

  • #90358

    Participant
    Points: 22
    Rank: Member
    Get-ItemPropertyValue | Get-Member
    

    You will get prompted for a value, just type name and enter twice and you should see a list of methods and properties. That is if I'm understanding what it is you are seeking.

    • #90392

      Participant
      Points: 0
      Rank: Member

      Not exactly but also good hint. If I can I will continue.
      I have a comment

      Get-ItemPropertyValue -Path C:\Users\karol\Desktop\Migration -Name LastWriteTime,CreationTime

      This are two property names "LastWriteTime,CreationTime" i have found over internet. I would like to know how, in this example, am I to find other values that can be passed to "Name".

      The "Get-Member" gives me type of the member and the of its methods and properties.

      Thx for answer

    • #90410

      Participant
      Points: 22
      Rank: Member

      I think you need to use the following first in order to discover what you can use:

      Get-ItemProperty -Path C:\Users\karol\Desktop\Migration

      This should give you some objects that you can refer to when using:

      Get-ItemProperty -Path C:\Users\karol\Desktop\Migration -Name LastWriteTime,CreationTime

      Refer to these two links for more info:
      Get-ItemProperty
      Get-ItemPropertyValue

    • #90499

      Participant
      Points: 0
      Rank: Member

      Thx you very much. A huge progress was made.
      But few more questions came up 🙂
      First thinks first. I started with

      Get-ItemProperty -Path C:\Users\karol\Desktop\Migration

      and it gave me almost nothing

      Directory: C:\Users\karol\Desktop

      Mode LastWriteTime Length Name
      —- ————- —— —-
      d—– 15/12/2017 14:20 Migration

      Bit then I find something like Format-List and it did the job.

      Get-ItemProperty -Path C:\Users\karol\Desktop\Migration  | Format-List

      The result was what i was looking for

      Directory: C:\Users\karol\Desktop

      Name : Migration
      CreationTime : 05/06/2017 09:32:10
      LastWriteTime : 15/12/2017 14:20:36
      LastAccessTime : 15/12/2017 14:20:36
      Mode : d—–
      LinkType :
      Target : {}

      So the first question is why i haven't seen anything without Formatting? Based on my understanding from other languages it should show us something. Not formatted, but something.

      So i was able to came up with something like this.

      Get-ItemPropertyValue -Path C:\Users\karol\Desktop\Migration -Name LastWriteTime,CreationTime,Name,Root

      It worked just fine. I won't be passing the result. The question is what is "Root"? Because i was not listed as a possible value for Name.

    • #90506

      Participant
      Points: 263
      Helping Hand
      Rank: Contributor

      Karol,
      I'd like to ask you to start learning the basics of Powershell first. In this process you will learn as well how to get some information about objects and how to use them. I think it is beyond the scope of this forum to teach you one cmdlet at a time.

      Some of the most common basic cmdlets are Get-Help, Get-Command, Get-Member and Select-Object. (Especially Select-Object -Property *)

      Here you can start learning PowerShell for free: Microsoft Virtual Academy – Getting Started with Microsoft PowerShell.
      With a basic understanding of Powershell you can even find some already written scripts and adapt them for your needs.
      Here you can find some: Powershell Gallery or TechNet Gallery – resources for IT professionals

    • #90517

      Participant
      Points: 0
      Rank: Member

      Hello.
      Few points

      1) I'm learning by going by some tasks. For me it is the best way.
      2) Thanks for materials. I will surely take a look on it.
      3) I don't believe this thread is above or below this forum. I'm asking question and someone is helping me. Maybe some people who are also starting will find it useful. Don't like to post, don't read it. It is that simple. If you believe topic or the way post is formatted is against the rules please feel free to report it to forum moderator/admin.

      Best regards

    • #90518

      Participant
      Points: 263
      Helping Hand
      Rank: Contributor

      I'm learning by going by some tasks.

      No. You're trying to learn by guessing.

      For me it is the best way.

      Sorry – in my opinion you're wrong with that conclusion.

      If you start learning the basics of Powershell all what you've asked will be clear in the first lessions. At least try the first lessions of the MVA course please.

    • #93619

      Participant
      Points: 0
      Rank: Member

      Hello

      I Just want to say you were right. I Started from the bottom and now working in PS daily.

      Mark it in calendar. Someone in the internet admitted to be wrong 🙂

      Best regards

    • #90551

      Participant
      Points: 320
      Helping Hand
      Rank: Contributor

      There are a couple of things to pull into focus here. Let's step though and show you what I mean. Run the below and see what you get back.

      Starting with stuff like using the built-in help files. 
      Even if you choose not to read it all (which you should), at minimum look at all the parameters and examples.
      
          Get-Help -Name Get-ItemProperty -Full
      
          Get-Help -Name Get-ItemProperty -Examples
      
      Then info on the cmdlet / function you are trying to use
      
          (Get-Command -Name Get-ItemProperty).Parameters
      
      
      Then what you can use the cmdlet/function on.
      
          Get-ItemProperty -Path D:\Temp | Format-Table -AutoSize -Wrap
      
          Get-ItemProperty -Path D:\Temp | Format-List
      
          Get-ItemProperty -Path D:\Temp | Format-List -Force
      
          Get-ItemProperty -Path D:\Temp | Select-Object -Property *
      
          (Get-ItemProperty -Path D:\Temp) | Get-Member
      

      You often cannot do just one thing and get all you need for X or Y, you have to expand your need approach to extrapolate data points.

      It's ok to experiment / try things, but ensure you do some prep before doing so as you can lead yourself to unnecessary frustration. PoSH is all about discovery (lots of trial, error, hacking and kludges sometimes). Yet taking a singular focus approach, well, is just painful and taking a look at how others have done things is always a good thing. Everyone learns from everyone, regardless of level. If you are like me, I am first and foremost a visual learner, YouTube, MS Channel9, TechNet virtual labs, and the stuff Olaf points to are good things.

      Here are a few more for you.

      Microsoft Channe9
      'channel9.msdn.com/Series/GetStartedPowerShell3'
      'channel9.msdn.com/Search?term=powershell#ch9Search&lang-en=en&pubDate=year'

      Windows PowerShell Survival Guide
      'social.technet.microsoft.com/wiki/contents/articles/183.windows-powershell-survival-guide.aspxStart-Process'

      eBooks...
      'blogs.technet.microsoft.com/pstips/2014/05/26/free-powershell-ebooks'
      'idera.com/resourcecentral/whitepapers/powershell-ebook'
      'powershell.org/ebooks'

      And start with lots of examples.
      'powershellgallery.com'
      'gallery.technet.microsoft.com/scriptcenter/site/requests'
      'technet.microsoft.com/en-us/scriptcenter/bb410849.aspx'

      Looking at the .ps* files already on your system. There are bunches of them located here:

      C:\Windows\System32\WindowsPowerShell\v1.0

      Just make a copy of that and open in the PowerShell_ISE.exe and review them.
      Heck even in the ISE just hit CRTL+J to see a list of prebuilt snippets to review and understand.

    • #90577

      Participant
      Points: 0
      Rank: Member

      Thanks you all very much for help.

  • #90361

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    There's no fixed list of what -Name will accept. It depends on what you are working with. For example, in the file system versus the registry versus something else. So you have to – as suggested above – retrieve something and ask for a member list.

The topic ‘Possible parameter values’ is closed to new replies.