Solved

Advanced Function (Get-Help not working)

Posted on 2011-02-16
2
599 Views
Last Modified: 2012-05-11
I have the following Advanced Function that I created and saved as "Add-GlobalGroup.ps1".

When I try to display the Help properties (i.e. get-help ./Add-GlobalGroup.ps1 -example or -detailed, etc.) it always returns the same thing:

PS C:\Scripts> get-help .\Add-GlobalGroup.ps1 -Example
Add-GlobalGroup.ps1 [-Domain] <String> [-Group] <String> [-Server] <String> [-Verbose] [-Debug] [-ErrorAction <ActionPr
eference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <Str
ing>] [-OutBuffer <Int32>]

PS C:\Scripts> get-help .\Add-GlobalGroup.ps1 -Full
Add-GlobalGroup.ps1 [-Domain] <String> [-Group] <String> [-Server] <String> [-Verbose] [-Debug] [-ErrorAction <ActionPr
eference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <Str
ing>] [-OutBuffer <Int32>]

What am I doing wrong?

Thank you!!

PS C:\Scripts> get-help .\Add-GlobalGroup.ps1 -Detailed
Add-GlobalGroup.ps1 [-Domain] <String> [-Group] <String> [-Server] <String> [-Verbose] [-Debug] [-ErrorAction <ActionPr
eference>] [-WarningAction <ActionPreference>] [-ErrorVariable <String>] [-WarningVariable <String>] [-OutVariable <Str
ing>] [-OutBuffer <Int32>]
#REQUIRES -Version 2.0
<#
.Synopsis
    Adds Global Group to Local Server Administrators Group
.Description
    This function adds the Global Group you provide to the Local Server Administrator's Group indicated.
.Parameter Corp
    Domain Name
.Parameter Group
    Global Group Name
.Parameter Server
    Target Server Name
.Example
    PS> Add-GlobalGroup Corp RES_IIS_WebFarm_Admin DSP01WEB 
.Link
    about_functions
    about_functions_advanced
    about_functions_advanced_methods
    about_functions_advanced_parameters
.Notes
NAME:     Verb-Noun
AUTHOR:   User
LASTEDIT: 02/15/2010 14:48:02
#Requires -Version 2.0
#>

[CmdletBinding()]
Param(
[Parameter(mandatory=$true,ValueFromPipeline=$true,position=0)]
[String]$Domain,

[Parameter(mandatory=$true,ValueFromPipeline=$true,position=1)]
[String]$Group,

[Parameter(mandatory=$true,ValueFromPipeline=$true,position=2)]
[String]$Server
)



Begin
{
Write-Host -foregroundcolor Yellow “Adding $Group to the Local Administrators Group of $Server”
}
Process
{
$adsi = [ADSI]"WinNT://$Server/administrators,group"
$adsi.add("WinNT://$Domain/$Group,group")
}
End
{
Write-Host “Bye bye!”
}

Open in new window

0
Comment
Question by:CodexK2
2 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 34909913
It doesn't like your #Requires statement at the top. Drop that and everything works. I can't actually get it to work with both the requires statement and the help-block.

Chris
0
 

Author Closing Comment

by:CodexK2
ID: 34925384
Worked perfectly - thank you!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question