Add-ADUsertoLocalGroup.ps1


Interesting stuff further down the page! 🤔


Description

Something about the lack of information and the thought about making as many scripts available as possible, regardless of any missing additional content.

Some information about the exciting thing…..that’s actually what will be here, rather than this filler text.

Please report any issues or suggestions using the link in the Report Issues section. If you report a requirement for more information, I can prioritise which pages are updated first. At present, I am working on adding information for each exciting thing contained within these pages.

Back to Top


Examples

This section will, in the near future, contain one or more examples of the script/function/etc in use and a small sample of the output and will hopefully prove somewhat more useful than the current content 🤷‍♂️

Back to Top


Script

This section can of course be copied in part or full. You can download the entire script by clicking the button in the download section.

function Add-ADUsertoLocalGroup {
    [CmdletBinding(DefaultParameterSetName = 'Default',
        HelpURI = 'https://scripts.lukeleigh.com/_posts/functions/Add-ADUsertoLocalGroup/')]
    param (
        [string[]]$ComputerName,
        [string[]]$UserName,
        [string[]]$LocalGroupName
    )
    if ($ComputerName -eq "") { $ComputerName = "$env:COMPUTERNAME" }
    [string]$domainName = ([ADSI]'').name
    ([ADSI]"WinNT://$ComputerName/$LocalGroupName,group").Add("WinNT://$domainName/$UserName")

}

# Write-Host "User $domainName\$userName is now member of local group $localGroupName on $computerName."

Back to Top


Download

Please feel free to copy parts of the script or if you would like to download the entire script, simple click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.

Back to Top


Report Issues

You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible. Something heartfelt about “Helping me, to help you…….?” or something like that…..I am sure you understand where I am coming from.

Issue

Back to Top