PS Simple Scripts

July 30, 2014

Installing Active Directory Certificate Services Windows 2012

Filed under: General — telnet25 @ 11:40 am

 

If you are looking into installing Certificate authority with widows 2012 server follow the simple steps listed in this article. Steps are pretty similar to windows 2008 CA installation

Step#1

Open Server Manager , Manage and Add Roles and Features

clip_image001[4]

Step#2

clip_image002[4]

Step#3

clip_image003[4]

Step#4

clip_image004[4]

Step#5

clip_image005[4]

Step#6

clip_image006[4]

Step#7

clip_image007[4]

Step#8

clip_image008[4]

Step#9

clip_image009[4]

Step#10

clip_image010[4]

Step#11

clip_image011[4]

Step#12

clip_image012[4]

Step#13

clip_image013[4]

Step#14

clip_image014[4]

Step#15

clip_image015[4]

Step#16

clip_image016[4]

Step#17

clip_image017[4]

Step#18

clip_image018[4]

Step#19

clip_image019[4]

Step#20

clip_image020[4]

Step#21

clip_image021[4]

Step#22

clip_image022[4]

Step#23

clip_image023[4]

Step#24

clip_image024[4]

Step#25

clip_image025[4]

Step#26

clip_image026[4]

Step#27

clip_image027[4]

Step#28

Open IIS

clip_image028[4]

Step#30

clip_image029[4]

Step#31

clip_image030[4]

Step#32

clip_image031[4]

Step#33

clip_image032[4]

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

July 23, 2014

Create Custom RBAC roles with quick powerfull cmdlets.

Filed under: General — telnet25 @ 1:49 pm

Here are some handy RBAC cmdlets to help you build your own custom Role Groups, role assignments etc. When you design RBAC Groups , you need to pay attention to your name convention to make sure , Groups, role assignments etc. makes sense, each Role Group created will be located on Microsoft Exchange Security Groups on the root of the forest/Domain , adding members to these security groups also possible using active directors users snap in, so you need to have plan to secure these groups. it might be good idea to tick the box “protect object from accidental deletion” for these groups.

image

image

image

#List all Management Roles

Get-ManagementRole

clip_image001

#List all role entries within given Management Role

Get-ManagementRoleEntry "View-Only Recipients\*"

clip_image002

Note: as you have noticed, all these cmdlet’s , user can run if the user is assigned to a Role Group = Assigned Role = ManagementRoleEntry

Here is simple snapshot to digest the relationship

clip_image003

#Create new Role from existing Parent Role

New-ManagementRole "HelpDesk Permissions" -Parent "View-Only Recipients"

clip_image004

#Remove all Role Entries , except selected one

Get-ManagementRoleEntry “HelpDesk Permissions\*” | Where {$_.name -ne “Get-User”} | Remove-ManagementRoleEntry -Confirm:$False

image

#Locate managementRole

Get-ManagementRoleEntry “HelpDesk Permissions\*”

clip_image006

#Add additional CMDLET if needed to management Role

Add-ManagementRoleEntry “HelpDesk Permissions\Get-MailboxPermission”

clip_image007

#Locate ManagementRole to verify desired cmdlet is assigned to it

Get-ManagementRoleEntry “HelpDesk Permissions\*”

clip_image008

#Create New Role Group

New-RoleGroup "HelpDesk 1.5"

clip_image009

#Add Role assignment to Role Group

New-ManagementRoleAssignment -SecurityGroup "HelpDesk 1.5" -Role "HelpDesk Permissions"

clip_image010

#add member to Role Group

Add-RoleGroupMember “HelpDesk 1.5” –Member C-Ron.Buzon

clip_image011

#locate members

Get-ManagementRoleEntry “HelpDesk Permissions\*”

clip_image012

#remove Members from desired Role Group

Remove-RoleGroupMember “HelpDesk 1.5” –Member C-Ron.Buzon

clip_image013

# Find desired user, List all the Roles

Get-ManagementRoleAssignment -GetEffectiveUsers | ?{$_.EffectiveUserName -eq “Administrator”} | select Role

clip_image014

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

July 15, 2014

How To Create CUSTOM RBAC ROLE Exchange 2010 & 2013

Filed under: General — telnet25 @ 8:53 pm

We would like to utilize RBAC Role model and create custom RBAC Role for specific needs for a business. These needs could be different from one environment to another. This article will be good reference for you to get your customization. Having said that, first thing to understand is the RBAC Layers.

There are 6 Layers which make up the Role Group Model

  • Role group member
  • Management role group
  • Management role assignment
  • Management role scope
  • Management role
  • Management role entries

clip_image001[4]

Goal:

  1. Create Custom Role Group
  2. Create Custom RBAC Role Entry with desired cmdlet’s
  3. Add Custom Role entry to Role
  4. Add role to Custom Role Group
  5. Add Members to Custom Role Group

In this example we will use following template

image

Note: You can build your own management Role , and modify management role entries same way in this article. The process is pretty straight forward.

Task#1

Figure out all role entry contains set-mailbox (set-mailbox is one of the cmdlet we have as our requirement)

Get-ManagementRoleEntry *\Set-Mailbox

clip_image002[4]

 

Task#2

Create the management role with related parent Role

New-ManagementRole -Name “Assign Mailbox Access” -Parent “Mail Recipients”

clip_image003[4]

Task#3

Get-ManagementRoleEntry "Assign Mailbox Access\*"

Verify all cmdlet assign to newly created management role, as you can see we have many cmdlet we don’t want, therefore we will need to remove most of them and only keep what we need.

clip_image004[4]

Task#4

Remove what you don’t need

Get-ManagementRoleEntry “Assign Mailbox Access\*” | Where {$_.name -ne “Add-MailboxPermission”} | Remove-ManagementRoleEntry -Confirm:$False

clip_image005[4]

Task#5

Verify the Role entry , minimum cmdlet is assigned.

clip_image006[4]

Task#6

Add additional cmdlet

  • Add-ManagementRoleEntry "Assign Mailbox Access\get-mailbox"
  • Add-ManagementRoleEntry "Assign Mailbox Access\get-mailboxPermission"
  • Add-ManagementRoleEntry "Assign Mailbox Access\remove-mailboxPermission"
  • Add-ManagementRoleEntry "Assign Mailbox Access\set-mailbox"

clip_image007[4]

Task#7

Add remove any role entries if desired

Verify one more time to make sure we have all we wanted. If required continue to add by using same one liner cmdlet

Add-ManagementRoleEntry "Assign Mailbox Access\set-mailbox" —————> you can replace set-mailbox

If you need to remove use

Remove-ManagementRoleEntry "Assign Mailbox Access\set-mailbox"

clip_image008[4]

Task#8

Create new Role Group

New-RoleGroup “Audit Team”

clip_image009[4]

Task#9

Let’s put them together

New-ManagementRoleAssignment -SecurityGroup "Audit Team" -Role "Assign Mailbox Access"

clip_image010[4]

Task#10

Add-RoleGroupMember “Audit Team” –Member C-Ron.Buzon

clip_image011[4]

We are done lets look at this from ECP

clip_image012[4]

clip_image013[4]

Now if c-ron.Buzon logs in, he will only get the cmdlets assigned to him via RBAC Role. As you can see RBAC permissions model is very efficient and effective. When creating Roles, group and Role entries, you may want to think about unifying name convention and plan this out before start implementing it into production environment.

TechNet:

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

July 9, 2014

Recovering from Accidentally Deleted AD objects with PowerShell , AD Recycle BIN , Windows 2012 Active Directory.

Filed under: General — telnet25 @ 7:58 pm

We will recovery accidently deleted user account via PS in windows 2012 domain environment. To prepare the scenario we will fist delete the user and recovery it.

Log onto  Windows 2012 DC with administrator privileges.Open PS with administrator privileges

Type following.

Get-ADUser -Filter ‘Name -like "*C-Ron Buzon"’

image

image

We will delete the user

Get-ADUser -Filter ‘Name -like "*C-Ron Buzon"’ | Remove-ADUser -Confirm:$false

image

user has been deleted

image

we can see user within the Deleted Objects container in ADAC

image

Get-ADobject -Filter ‘Name -like "*C-Ron*"’ -IncludeDeletedObjects

image

we will restore this user

Get-ADobject -Filter ‘Name -like "*C-Ron*"’ -IncludeDeletedObjects | Restore-ADObject

image

if I check to see user is back to ADDS

image

image

Read more

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

 

Installing First Windows 2012 Domain Controller into Existing Forest/Domain via PowerShell

Filed under: General — telnet25 @ 7:54 pm

 

Task: Introducing first Windows 2012 domain controller into Existing Forest /Domain. As you already  notices with Windows 2012 , promoting server to be additional domain controller is changed a lot. There is no more DCpromo instead we use GUI or PowerShell to get the work done.

High Level Steps :

  • Install Windows 2012 Server
  • Configure , Server name, IP address
  • Add Server into existing domain as member server ( preferred )
  • Use PS to promote the server to be additional domain controller and modify the DCpromo.ps1 Script

Step# 1

First task is to add the windows 2012 server into existing domain. Adding server into existing domain  before promoting to be domain controller is a good old habit ,  which allows A record to be created  within the existing DNS Forward lookup  zone and helps also ensures correct DNS settings has been configured.

Log into Server

Open PowerShell and type following command.

Install-WindowsFeature -Name Ad-Domain-Services | Install-WindowsFeature

clip_image001

Step# 2

Now copy and paste the , below PowerShell command into notepad , and save it as DCpromo.ps1 ( we use this name to honor DCPromo we have used ages (-:   , you can name it anything you like.

image

You will need to change  “-DomainName "ZtekZone.com"  and if you like any additional customization , such as changing the defaults , SYSLOG, DatabasePath, LogPath etc.

Download the script from here

Run PS Command against pre-defied PS Script

#Installing Domain Controller

Write-Host "………………………….."

Write-Host "Please modify pre defined Script "

Write-Host "To Make sure it fits into your Environment"

Write-Host "………………………….."

Import-Module ADDSDeployment

Install-ADDSDomainController `

-NoGlobalCatalog:$false `

-CreateDnsDelegation:$false `

-CriticalReplicationOnly:$false `

# Change the DatabasePath if desired

-DatabasePath "C:\Windows\NTDS" `

# Change the Domain name if desired

-DomainName "ZtekZone.com"

-InstallDns:$true `

# Change the LogPath if desired

-LogPath "C:\Windows\NTDS" `

-NoRebootOnCompletion:$false `

# Change the AD Site Name if necessary

-SiteName "Default-First-Site-Name" `

# Change the SYSVOL if necessary.

-SysvolPath "C:\Windows\SYSVOL" `

-Force:$true

Now after modifying the script save it onto server into temp Directory

image

From PowerShell Run it

clip_image002

clip_image003

clip_image004

After server reboot if we open Site and Services we will see the additional domain controller

clip_image005

Now couple additional Configuration we will perform on the new domain controller

Add-WindowsFeature RSAT-AD-PowerShell, RSAT-AD-AdminCenter

clip_image006

Now you can open ADAC from GUI

clip_image007

Or you can open it from PowerShell

clip_image008

clip_image009

You can also open Site and Services

dssite.msc

clip_image010

You can open ADUC

Dsa.msc

clip_image011

More to read… AD Team

http://blogs.technet.com/b/askpfeplat/archive/2012/09/06/introducing-the-first-windows-server-2012-domain-controller-part-2-of-2.aspx

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

Installing Windows 2012 Core as additional Domain Controller into Existing Forest/Domain. Sconfig is your Friend.

Filed under: General — telnet25 @ 7:46 pm

 

After finishing window 2012 server install , and logging into server all we get is  plain command prompt. If you are tasked to promote this newly installed  Core Server to be the additional domain controller you can use Sconfig to get the mission accomplish.

Type “Sconfig” and hit enter

image

image

Now first thing we will do is to rename the server

Option # 1

image

 

image

we will say no to this one for now, we will set the IP Address

Option # 8

image

Type the index number shown on the menu for the adapter you wish to configure

image

Option # 1

and select Static ( S )

image

as you can see the new configured IP is showing up next to 169.254.1.121

Now we need to take care of  DNS IP Addresses

Option # 2

image

image

image

Option # 4 return the Main Menu

image

Enable RDP Option # 7

image

and now I am going to re-start the server

image

After I login I made sure I can ping my existing DC/GC/DNS Server

image

Firing up SConfig one more time to add the server into existing domain as member server

image

image

Now server is part of the domain and ready to be promoted as additional domain controller

I make sure to log back into domain

image

Now lets fire-up PowerShell

image

image

Fire-up Sconfig  one more time to make sure I have the correct, desired configuration settings.

image

 

Install-WindowsFeature -Name Ad-Domain-Services | Install-WindowsFeature

image

Type notepad.exe on the PS and hit enter

image

Copy and paste below code into notepad.

Core.ps1 ( You need to change the desired filed in the PS script , such as domain name

I have used “-DomainName "ZtekZone.com" change this to suit to your scenario. Once you are done, on the notepad click file and save as , and save the file on the C:\temp directory as “CoreDeploy.ps1”

image 

You can download the script from here

image

 

#Installing Domain Controller

Write-Host "………………………….."

Write-Host "Please modify pre defined Script "

Write-Host "To Make sure it fits into your Environment"

Write-Host "………………………….."

Import-Module ADDSDeployment

Install-ADDSDomainController `

-NoGlobalCatalog:$false `

-CreateDnsDelegation:$false `

-CriticalReplicationOnly:$false `

# Change the DatabasePath if desired

-DatabasePath "C:\Windows\NTDS" `

# Change the Domain name if desired

-DomainName "ZtekZone.com"

-InstallDns:$true `

# Change the LogPath if desired

-LogPath "C:\Windows\NTDS" `

-NoRebootOnCompletion:$false `

# Change the AD Site Name if necessary

-SiteName "Default-First-Site-Name" `

# Change the SYSVOL if necessary.

-SysvolPath "C:\Windows\SYSVOL" `

-Force:$true

Now within the PS , change the directory to C:\temp directory

image

 

Type “CoreDeploy.ps1”

image

 

image

ZtekZone.com ( is the domain name in my case)

image

image

After server reboots , you need to make sure replication is working etc.

here is AD site and services with the newly promoted server

image

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

Largest collection of FREE Microsoft eBooks ever, including: Windows 8.1, Windows 8,PowerShell, Exchange Server, Lync 2013, System Center, Azure, Cloud, SQL Server

Filed under: General — telnet25 @ 10:27 am

 

MS has large e-book offerings , click here to get them

 

image

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

July 7, 2014

Installing First Windows 2012 Domain Controller into Existing Forest/Domain via PowerShell

Filed under: General — telnet25 @ 5:44 pm

 

Task: Introducing first Windows 2012 domain controller into Existing Forest /Domain. As you already  notices with Windows 2012 , promoting server to be additional domain controller is changed a lot. There is no more DCpromo instead we use GUI or PowerShell to get the work done.

High Level Steps :

  • Install Windows 2012 Server
  • Configure , Server name, IP address
  • Add Server into existing domain as member server ( preferred )
  • Use PS to promote the server to be additional domain controller and modify the DCpromo.ps1 Script

Step# 1

First task is to add the windows 2012 server into existing domain. Adding server into existing domain  before promoting to be domain controller is a good old habit ,  which allows A record to be created  within the existing DNS Forward lookup  zone and helps also ensures correct DNS settings has been configured.

Log into Server

Open PowerShell and type following command.

 

Install-WindowsFeature -Name Ad-Domain-Services | Install-WindowsFeature

 

clip_image001

Step# 2

Now copy and paste the , below PowerShell command into notepad , and save it as DCpromo.ps1 ( we use this name to honor DCPromo we have used ages (-:   , you can name it anything you like.

image

You will need to change  “-DomainName "ZtekZone.com"  and if you like any additional customization , such as changing the defaults , SYSLOG, DatabasePath, LogPath etc.

‘>’>Download the Script from here if  you prefer

 

Run PS Command against pre-defied PS Script

#Installing Domain Controller

Write-Host "………………………….."

Write-Host "Please modify pre defined Script "

Write-Host "To Make sure it fits into your Environment"

Write-Host "………………………….."

Import-Module ADDSDeployment

Install-ADDSDomainController `

-NoGlobalCatalog:$false `

-CreateDnsDelegation:$false `

-CriticalReplicationOnly:$false `

# Change the DatabasePath if desired

-DatabasePath "C:\Windows\NTDS" `

# Change the Domain name if desired

-DomainName "ZtekZone.com"

-InstallDns:$true `

# Change the LogPath if desired

-LogPath "C:\Windows\NTDS" `

-NoRebootOnCompletion:$false `

# Change the AD Site Name if necessary

-SiteName "Default-First-Site-Name" `

# Change the SYSVOL if necessary.

-SysvolPath "C:\Windows\SYSVOL" `

-Force:$true

Now after modifying the script save it onto server into temp Directory

image

From PowerShell Run it

clip_image002

clip_image003

clip_image004

After server reboot if we open Site and Services we will see the additional domain controller

clip_image005

Now couple additional Configuration we will perform on the new domain controller

Add-WindowsFeature RSAT-AD-PowerShell, RSAT-AD-AdminCenter

clip_image006

Now you can open ADAC from GUI

clip_image007

Or you can open it from PowerShell

clip_image008

clip_image009

You can also open Site and Services

dssite.msc

clip_image010

You can open ADUC

Dsa.msc

clip_image011

More to read… AD Team

http://blogs.technet.com/b/askpfeplat/archive/2012/09/06/introducing-the-first-windows-server-2012-domain-controller-part-2-of-2.aspx

Respectfully,
Oz Casey, Dedeal ( MVP north America)
MCITP (EMA), MCITP (SA)
MCSE 2003, M+, S+, MCDST
Security+, Project +, Server +
http://smtp25.blogspot.com/ (Blog)
https://telnet25.wordpress.com/ (Blog)

Create a free website or blog at WordPress.com.