Showing posts with label PowerShell Basics. Show all posts
Showing posts with label PowerShell Basics. Show all posts

Sunday, April 9, 2017

PowerShell Basics : Find commands by using Get-Command cmdlet.

 

Sometimes, the more we do advance things, the more we keep forgetting the  basics.

Today while working on some script, I forget the command  which I need to use.

I do know the module name of the command which it belongs to… So I just my little helpful cmdlet Get-Command –Module MoDuleName

and it showed me all the command of that particular module and along some some other useful commands too.

 

Smile 

AmanDhally - PowerShell

Happy PowerShelling..

 

Regards

Aman Dhally

Tuesday, May 10, 2016

PowerShell cmdlet of the Day : Start-Sleep


Sometime, the more we move ahead, the more we start forgetting the basic things. It's in human nature I think or may be in mine :P .
Today when I was working on a PowerShell script, I come along with a cmdlet which I have used a lot in my early scripts.
The forgot cmdlet is "Start-Sleep".
It's hold the script activity for the period defined in it and it move to next line in the script after the define time in lapsed. For example if you set the Start-Sleep -Seconds 10, then it moved to next line after 10 seconds only.
Aman Dhally , Manya Kaur
The usage is simple., type Start-Sleep and then either use -seconds or -Milliseconds parameter and provide the value in number.

Simple, isn't :)

With 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”.

Monday, November 23, 2015

PowerShell & Microsoft Word 2016 : Opening Clipboard in Word 2016 using PowerShell.

 

In the previous blog posts, we have seem that how can we set the zoom view of a document.

Ok!, this task seems to be tricky one, they ( those wizards), asked me to open Word Clipboard!!!! What!!!!!!

Yes, they asked me if I can open a word clipboard using PowerShell.

At , first , it seems to be a tough job for me , but, you do remember that PowerShell is easy? Yes?

After few hit and tries, I have found it out, it's veryyyyyy simple. Word COM object have a method  by the name of ShowClipboard ( ) .

Simple!!!!!

$word.ShowClipboard()

The complete code is :

 

$word = New-Object -ComObject "Word.Application"

$word.Visible = $true

$word.ShowClipboard()

Aman Dhally - Manya Kaur

Now' let's see, what will be the next challenge may be!

Aman Dhally - Manya Kaur

With 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”.

Tuesday, October 13, 2015

PowerShell and BitLocker : Create a Password Protected encrypted drive.

 

In the previous blog post , we discussed a little bit about BitLocker. And we  also see that how can user Get-BitLockerVolume to show us all the drives, including encrypted and non-encrypted one.

Today, we are going to see, how can we encrypt password protected drive using BitLocker Powershell module cmdlets.

When  I run the Get-BitLockerVolume cmdlet, it shows me the below output, you can see , that I have two drives are both are not encrypted.

I am interested in encrypting my Data Drive which is drive letter D:\.

Let's encrypt it.

1

To encrypt a drive, we use the Enable-BitLockerVolume cmdlet

Remember: We need to create a Secure String Password, if you want to open the BitLocker encrypted drive using Password.

$pass = ConvertTo-SecureString "Passw0rd" -AsPlainText -Force

In above command, we are creating a new secure string of text, Passw0rd, this will be out password to unlock the BitLocker encrypted drive.

Enable-BitLocker -MountPoint D:\ -EncryptionMethod Aes128 -Password $pass -PasswordProtector

 

In abov command, we are using Enable-BitLocker to encrypting our drive, in -MountPoint, we are providing the drive letter of the disk which we want to encrypt, in -EncryptionMethod we are providing, which type of encryption we are going to use, it can be either Aes128 or Aes256 , in -Password we have provided the variable $pass in which our secure string is strored, and then -PasswordProtector parameter.

 

Now it the enter, you can see that the BitLocker has started the encrypting the drive...

2

3

In the next blog post, we will see that how can we mount encrypted drives using PowerShell.

Take care till then.

Aman Dhally

With 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”.