Showing posts with label Automation. Show all posts
Showing posts with label Automation. Show all posts

Tuesday, June 23, 2015

Managing Windows Server 2012 R2 Using PowerShell : Part-7 : Joining Server to the domain.

 

  1. Part 1 : Windows Server 2012 R2 Installation.
  2. Part 2 : Exploring PowerShell Default Settings.
  3. Part 3 : Getting and setting server name.
  4. Part 4 : Getting IP Address of the server.
  5. Part 5 : Setting IP Address of the server.
  6. Part 6 : Checking if Server is member of domain.

Part - 7 : Joining to the domain.

Configuration

In the previous blog post, we have see, that how can we  check if the server is the part of the domain or not.

Today, we are going to add our server to the domain, and make it the member of our domain environment.

Adding to the domain ( non PowerShell way ).

We can add our server to the domain in two ways. One is by adding it manually and the second way is by using the NetDom.exe command.

  1. Manually ( I am sure, that you know, how to do that)
  2. By using the NETDOM.exe command.
    1. Aman Dhally , Manya Kaur
    2. usage of Netdom.exe is simple. you can visit this link to know about, how can use use it.  https://support.microsoft.com/en-us/kb/150493)

Adding to the domain ( The PowerShell way )

Adding server to domain by using PowerShell is very simple. To add server to a domain using PowerShell, we mainly need two things.

  1. Username and Password with domain adding privileges (admin account may be ).
  2. Domain Name.

To keep things simple for now, we are going to to the following:

  1. Saving username and password in to variable using Get-Credential cmdlet.
  2. Add server to the domain, by using Add-Computer cmdlet.

Let's start.

let's save our admin username and password in to a $credential variable. When you run the below command, it opens a credential window, provide your domain admin account username  ( or account with adding to domain privileges ) and it's password.  I main use the DomainNam\UserName format in username tab.

 

$credential = Get-Credential

 

1

 

Now, run the Add-Computer cmdlet, in -Credential parameter provide the name of variable which we have created above, and in -DomainName provide the name of domain name and hit enter.

 

Add-Computer -Credential $credential -DomainName 'myDomain.com'

 

2

In the above screenshot you can see, that our above command has run successfully and telling us to restart our server, Let's restart it.

After restarting the server, it was asking me for domain username and password to enter ( that means it joins to the domain successfully) , after login in , I checked using PowerShell, if the server is member of domain or not, in the below screenshot you can see, it is.

3

That's all for now, see you in my next blog post.

tumblr_ma3iifkEXw1r19a45o5_250

Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.

Thursday, September 19, 2013

Change windows Login Screen using Powershell.


Hi,
We all love customization and personalize our laptop setting. Like we all (majority of) love to change our wallpapers.
windows-7-logon-background
I have few scripts, which rebooted a laptop twice thrice, on those scripts i use Logon screen as a information and “how to’s” board.
backgroundDefault
and if you want some fun , you can also change the login screen with your choice of picture.
How to change login screen?
  1. Make sure the picture which you want to set as Login Screen is less then 254KB
  2. Rename the picture to “backgroundDefault.jpg
  3. A2
Run Powershell as Administrator.

Now, we need to set “OemBackgroud” value to 1 in the registry

Set-ItemProperty -Path hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background 
 -Name OEMBackground -Value 1
 
A1

Now copy the “backgroundDefault.jpg”  to the "C:\Windows\System32\oobe\info\backgrounds\" folder.

Copy-Item -Force "c:\myscripts\backgroundDefault.jpg" 
 "C:\Windows\System32\oobe\info\backgrounds\" -Verbose

A3

Now, to test, lock you screen (Windows Key + L ) and see if logon screen is changed or not.

But mine is changed :)

IMG-20130919-00495




How to set login screen to default again?

To set logon screen to default again, set the OEM key to “0” again.

Set-ItemProperty -Path 
hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background  
-Name OEMBackground -Value 0

I hope that you find is useful.

Aman Dhally

clip_image001 clip_image002 clip_image003 clip_image005clip_image007

Friday, August 30, 2013

Powershell and Outlook : Create and send a new email using Powershell “OutlookTools” Module.

 

Hi,

I have added a new functionality in “OutlookTools” module. Now we can compose and send a new emails using “New-OutlookEmail” function.

This function also do support adding attachments to the composed email, but for now we can attach only one single file.

“OutlookTools” Module download link: https://github.com/AmanDhally/OutlookTools

Let’s start

 

  1. First download the “OutlooTools.Psm1” and .psd1 file fromhttps://github.com/AmanDhally/OutlookTools
  2. Create a folder Name “OutlookTools” in “Libraries\Documents\WindowsPowershell\Modules
  3. and paste both files there.

12-08-2013 1 
Now open Powershell console and run the cmdlet, 

Import-Module OutlookTools

12-08-2013 2

By running the Get-Command cmdlet, we can see which cmdlet and function this modules had added.

Get-Command -Module outlooktools

0

You can see now , we have New-OutlookEmail listed in Function.

How to use it?

It’s simple.

Create a new email.

We are creating a new email , to amandhally@gmail.com with subject “Sending from Powershell” and with body text “Heya its working”

New-OutlookEmail -To amandhally@gmail.com -Subject "Sending from Powershell" -Body "Heya! its working"

1

and when you hit enter, you encountered this problem. ,

I haven’t solved it yet and i am working on it. :( .

2 

but when you click on “Allow”. this will send an email.

You can see, the email is come to our Sent Items folder.

3

and i received it on my Gmail id too.

4

Now create an email with attachment.

Now , we are creating a new email , with attachment, and with High Priority.

New-OutlookEmail -To "amandhally@gmail.com" -Subject "Attaching file"  -Attachment 'D:\a.txt' -importance 2

5

now when you click on send, the above problem comes again with one more confirmation box.,

6

7

once you click on Allows on both.

the email will be in Sent Item

8

and i received it on my Gmail id with attachments too.

9

“OutlookTools” Module download link: https://github.com/AmanDhally/OutlookTools

i hope you will like it.

Thanks
Aman Dhally
clip_image001 clip_image002 clip_image003 clip_image005clip_image007