just not working for me.

This topic contains 4 replies, has 3 voices, and was last updated by  Ivan 3 months, 1 week ago.

  • Author
    Posts
  • #75025

    Matthew
    Participant

    I have been watching some of MVA Videos Getting Started with MS power shell. I am trying to write custom help but is not working. as far as I understand it should be as simple as

    I even tried copying something and that worked. but then I tried to change it stopped working and I changed it back and it still did not work
    .Example
    ./hello.ps1 and that worked then I changed >/hello.ps1 to "whatever" example did not show up again and when I changed it back it still did not work.
    I figure it is some small thing I am missing that when I find out what it is I am going be like wow.
    I am using powershell 5.1. did any of this change from version 3.

    I will appreciate any help please

  • #75028

    Don Jones
    Keymaster

    If you're referring to comment-based help, it's definitely not hard. However, keep in mind that you can't paste XML and some other code here – you need to use a Gist, as indicated in the posting instructions.

    Comment-based help is very picky indeed, and you may have simply misspelled something. If you could create a Gist with what you're attempting, and paste the Gist link here, I'd be happy to take a look.

  • #75031

    Don Jones
    Keymaster

    You can also try pasting your code here, but tag it as code – again, as indicated in the instructions above the reply text box, using PRE tags.

    Finally, as a suggestion for getting better responses, consider a more meaningful subject when you post. "Just not working for me" doesn't tell us much about the problem, and many people will simply ignore the post. A subject like, "comment-based help problem" much more clearly describes the problem, so that people familiar with that topic know to jump in and help.

  • #75032

    Matthew
    Participant

    Don,
    Thank you, I really appreciate the advice, I have never really post before so I am somewhat new at it.
    As you suggested I am posting the code I am using.
    This is just a simple script to get the BIOS version of a remote computer. I am trying to just do some simple scripts/modules to get the hang of writing them and I think part of writing a good script/module would include comments and help.

    
    function Get-BIOSVersion
    {
    param(
        [Parameter(Mandatory=$True, Position=1)]
        [string[]]$ComputerName
    )
    Get-WmiObject -ComputerName $ComputerName -class win32_Bios
    
    }

    I believe there is an issue with the param computername as well.
    As you can see I am very new at this and I am thinking it just missing something small.

    Thank you again for your help

  • #75048

    Ivan
    Participant

    Hi Matthew,

    I'm going to guess here, but, I'll bet that you get NOTHING when you run your script (for illustration purposes say you saved the code you posted as Get-BIOSVersion.ps1), if that's the case, yes, you will get NOTHING because you have a function in there, but if you only save this code:

    param(
        [Parameter(Mandatory=$True, Position=1)]
        [string[]]$ComputerName
    )
    Get-WmiObject -ComputerName $ComputerName -class win32_Bios
    

    Then it will work.

    For more info check THIS VIDEO it will help you understand what's going on.

You must be logged in to reply to this topic.