Hi Everyone in this script when there is no space between the commend and <#
I do not get the full help section that I am looking for. But when I have a blank line in-between them the help section shows up properly. I took a look at this and in example two it seems related.
If someone could provide some input that would be great!
Im trying understand has much has I can.
#This is a block comment
<#
.Synopsis
This script gets you the storage space on the localhost(your computer) or remote computer for the C: drive
.Description
This will make things easier to grab storage information
.Parameter ComputerName
This is for remote and local computer
.Example
.\get_freespace_cdrive.ps1 -computername āSome name hereā
Shows how to do it on a remote computer
#> #This turns on the ability to use parameter attributes , For here it will serve the purpose of making things mandatory
[cmdletBinding()]
#paramitize so then script wont get edited
param( #Line 12 ONLY EFFECTS THE NEXT parameter after it SO IT WONT EFFECT $BOGUS VARIABLE
[Parameter(Mandatory=$true)]
[String]$ComputerName
) #Gets us the free space on the c: drive in Gbs !
Get-WmiObject -ComputerName $ComputerName -class win32_logicaldisk -Filter "DeviceID = āc:ā "
Iām not sure if I got what your question is. When I save the following code to a file with the path D:\sample\test.ps1 ā¦
<#
.Synopsis
This script gets you the storage space on the localhost(your computer) or remote computer for the C: drive
.Description
This will make things easier to grab storage information
.Parameter ComputerName
This is for remote and local computer
.Example
.\get_freespace_cdrive.ps1 -computername āSome name hereā
Shows how to do it on a remote computer
#>
[cmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[String]$ComputerName
)
Get-WmiObject -ComputerName $ComputerName -class win32_logicaldisk -Filter "DeviceID = 'c:' "
And run the command ā¦
Get-Help D:\sample\empty\Test.ps1 -Full
ā¦ I get the following output:
NAME
D:\sample\empty\Test.ps1
ĆBERSICHT
This script gets you the storage space on the localhost(your computer) or remote computer for the C: drive
SYNTAX
D:\sample\empty\Test.ps1 [-ComputerName] <String> [<CommonParameters>]
BESCHREIBUNG
This will make things easier to grab storage information
PARAMETER
-ComputerName <String>
This is for remote and local computer
Erforderlich? true
Position? 1
Standardwert
Pipelineeingaben akzeptieren?false
Platzhalterzeichen akzeptieren?false
<CommonParameters>
Dieses Cmdlet unterstĆ¼tzt folgende allgemeine Parameter: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter
"about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216).
EINGABEN
AUSGABEN
-------------------------- BEISPIEL 1 --------------------------
PS C:\>.\get_freespace_cdrive.ps1 -computername āSome name hereā
Shows how to do it on a remote computer
VERWANDTE LINKS
The key words are in German because I have a German system but the output seems correct to me.
BTW: When you post code or sample data or console output please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks in advance
If the first item in the script body (after the help) is a function declaration, there must be at least two blank lines between the end of the script help and the function declaration. Otherwise, the help is interpreted as being help for the function, not help for the script.
I think your problem is here:
#>
#This turns on the ability to use parameter attributes , For here it will serve the purpose of making things mandatory
[cmdletBinding()]
#paramitize so then script wont get edited
param(
Not enough empty lines between [cmdletBinding()] and the end of the help section.
Ok, but do you really need an additional comment line right in front of a big block comment? Thatās waht I meant - I donāt understand whatfor you need this particular comment there.
If you insist to have a comment line at the top of your script file you could make your code a function and add the comment base help inline in this function.
So did some testing. It appears the docs are incorrect. Any comment just before the help section breaks the help section. I put 2 spaces before and after and it all works fine in PS 5.1 and 7.2.
Great catch! Olaf may also be correct about language settings. Are you using UTF8 encoding on your script files? By default PowerShell uses UTF8 for reading/writing. I tested with UTF8 and UTF16.
Thank @stevething I think thatās what I was trying to explain but I did a poor job, sorry about that!
The more I keep posting the better I will be able to communicate what Iām trying to explain.
Can we contact someone about this, I know its really ānothingā but it might be worth it?
Yea I havenāt changed any language settings so I should be on default.