Windows way to Digital Learning……

Archive for the ‘Powershell | Scripting’ Category

Gallery

List Domain Users having the dial-in permission in AD

List Domain Users having the dial-in permission in AD

Download the RRAS-vbs script and save the file.

Once script  execution completes it will output a file called rras_vpn_users.txt in same folder as script.

Using Dsquery :

Run command prompt on a Domain Controller and then run the below command.

dsquery * -Filter “(&(objectCatgegory=person)(objectClass=user)(msNPAllowDialin=TRUE))”

 

PowerShell Get-ADUser (with AD modules):

Get-ADUser -LDAPFilter “(&(objectCategory=person)(objectClass=user)(msNPAllowDialin=TRUE))”

Advertisements

Shortcut To Run PowerShell with Elevated Permissions

Shortcut To Run PowerShell with Elevated Permissions

In order to run the PowerShell.

1. Press Windows Key

2. Type PowerShell

3. Right Click  Powershell Icon

4. Select Run as Administrator

Shortcut:

1. Press Windows Key

2. Type PowerShell

3. Press these keys combination Shift + Control + Enter

 

Note:  If you running from domain user / local user account it may ask you for administrator authentication.

How to Change the Local Administrator Password on Domain Member Computers.

We will discuss here two methods to change local administrator password.

First method using Power Shell / Script.

Script:

Set WshNetwork = WScript.CreateObject(“WScript.Network”) strComputer = “.”
Set objUser = GetObject(“WinNT://” & strComputer & “/Administrator,user”)
objUser.SetPassword “NEW.PASSWORD” ‘ Enter new password between brackets
objUser.SetInfo

 

Download the complete powershell script from here.

Second Method using GPP.

There is a Group Policy Preference (GPP) that can do it for you.

Changing the local Administrator password on domain members.

Start the Group Policy snap-in, expand Computer Configuration, expand Preferences, click Control Panel, and then right-click Local Users and Groups. From the menu select New – Local User.  Select Update as the action, type Administrator into the User name text box, then type the new password into the Password text box, confirming the password in Confirm Password text box. Press OK.

More information:

Creating Bulk Users using Power Shell

Creating Bulk Users Using Power Shell.

#########################################################
#
# Name: BulkCreateUsers.ps1
# Author: Tony Murray
# Version: 1.0
# Date: 10/11/2009
# Description: PowerShell script to bulk create users
#
#########################################################

### Variables

# Get the logged-on user’s domain in DN form
$mydom = (get-addomain).distinguishedname

# Specify the OU we want to create the users in
$ouName = “User Accounts”

# Build the full DN of the target OU
$oudn = “OU=$ouname,$mydom”

# Specify the number of users to create
$userCount = 50

# Specify the description attribute for the users
$datetime = get-date -format G
$desc = “Test user created $datetime”

### Start doing things

# Check if the target OU exists. If not, create it.
$OU = get-adorganizationalunit -Filter { name -eq $ouname }
if($OU -eq $null)
{New-ADOrganizationalUnit -Name $OUName -Path $mydom}
else
{write-host “The OU” $ou “already exists – this is good…”}

# Create users

$i = 1
While ($i -le $usercount)
{
$Uname = “User” + $i
$UDdname = “Test User” + $i
New-ADUser –Name $Uname –SamAccountName $Uname –DisplayName $UDdname `
-Path $oudn –Enabled $true –ChangePasswordAtLogon $true -description $desc `
-AccountPassword (ConvertTo-SecureString “P@ssw0rd” -AsPlainText -force) -PassThru
$i = $i + 1
}

#End

Code taken from http://www.activedir.org

Download scripts by Andy Grogan.

 

Tag Cloud