Import thumbnailphoto in AD from jpg

The script below will import Jpg file as a thumbnail photo in Active Directory

~Pouyan

Creating and using Password Hashes and Secure Strings with Powershell

This is how you can generate a Secure String with powershell and use it in your scripts

Load the Secure string from file and use it in your script:

How to uninstall with msiexec using product id guid

You can find the product code by perusing the registry from this base key: HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall . Press F3 and search for your product name. (If it’s a 32-bit installer on a 64-bit machine, it might be under HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall instead).

Finally, you can find the product code also by using PowerShell:

when you found the Guid ID you can use msiexec to uninstall the application

 

PowerShell – How to find details of Operating System

There were several instances where I had to find details of the operating system using PowerShell. Here, I am providing several PowerShell snippets that return various details of the Operating System.

Name of the Operating System

Is Operating System 32-bit or 64-bit

Name of the Machine

There are many more properties of the Operating System that are exposed. To obtain more details, run the following

 

PowerShell – Get Disconnected Mailbox in Exchange Server

If you delete a AD user account it will automatically disconnect the connected mailbox from the AD account and add it to the Disconnected Mailbox list.

Mailbox  will be listed until retention period of 30 days(unless otherwise set)

Gets the list of Disconnected mailbox in the specified Exchange 2007 Server

 

Create FTP user (Powershell GUI)

Here is a small PowerShell script that I have written today, this is a GUI interface script that will help you create a FTP user with folder and will configure the permissions fore IIS:

Well you can use the script to start the GUI both you can also convert this to a EXE file, to convert the script to a EXE you can  download PS2EXE

Now you can run the coede below to confert the PS1 file to a EXE file

  • Start powershell in version 2 (if you are running version 3)
  • Browse to the folder where you unzipt the PS2EXE and run the code

~pouyan

PowerShell – WmiObject and a corrupt repository

If repository is found to be inconsistent, for Vista and newer, run from elevated command prompt:

Note this command will take the content of the inconsistent repository and merge it into the rebuilt repository if it is readable

If the above doesn’t work, then run:

Note this will reset repository to the initial state when the OS was first installed

~pouyan

Using PowerShell as the Shell on Windows Server Core

With PowerShell becoming one of the most important tools in a Windows administrator’s tool bag as well as really becoming the best prompt to use on Windows Server Core, I thought it was about time I documented how to change the command prompt that opens when you log into Server Core with a PowerShell prompt.

To complete this requires two steps:

  1. Enable/Install PowerShell on the Windows 2008 R2 Server Core computer
  2. Update the HKLMSoftwareMicrosoftWindows NTCurrentVersionWinLogonShell registry key replacing cmd.exe with PowerShell.exe

To enable PowerShell run SCONFIG from the command prompt and then select menu options 4 then 2. This will require the computer to be rebooted

Once rebooted login and in the CMD prompt type PowerShell. At the PowerShell prompt type:

Having completed above log off and back on and a powershell prompt will open instead.

~Pouyan

Set Computer Name using PowerShell

Yesterday I faced a problem in which I need to change the computer name using PowerShell. First I was looking for some cmdlet which can do this job for me but there is not any builtin cmdlet for it.
This method is using WMI to do the task.

I am using Get-WMI to give me all the value of Win32_ComputerSystem.

You can see in the Output that the “Name” value contain our Computer name.

After putting the command in to the $computerName variable, you can use the rename method to rename the computer.


The Win32_ComputerSystem WMI class contain the method of .Rename() in which we need to provide a desired computer name in brackets.

~Pouyan

Displaying Balloon Tip

Let’s assume your script wants to share status information via a balloon message in the system tray area. Here is a sample:

Note that the code uses the icon of your PowerShell application inside the tray area so the user can associate the message with the application that produced it.