?
Solved

Advanced Function (Get-Help not working)

Posted on 2011-02-16
2
Medium Priority
?
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 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

WatchGuard's M Series Appliances - Miecom Approved

WatchGuard's newest M series appliances were put to the test by Miercom.  We had great results and outperformed all of our competitors in both stateless and stateful traffic throghput scenarios! Ready to see how your UTM appliance stacked up? Download the Miercom Report!

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

777 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