Solved

Advanced Function (Get-Help not working)

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Set OWA language and time zone in Exchange for individuals, all users or per database.
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

789 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