Solved

Advanced Function (Get-Help not working)

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 powershell/cmd/bash alternatives? 11 43
PowerShell select-object returns empty lines 3 17
Powershell script 13 74
Powershell Modification Requests 17 26
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
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 …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

16 Experts available now in Live!

Get 1:1 Help Now