Solved

Advanced Function (Get-Help not working)

Posted on 2011-02-16
2
594 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now