Search The Web

Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Tuesday, April 8, 2014

Use Powershell to Uninstall or Install Windows Roles and Features

Use Powershell to Uninstall or Install Windows Roles and Features 

You can use Powershell or uninstall or install Windows Roles and Features instead of using the GUI. This is especially useful in two scenarios : Server Core installations and also for scripting (new server installs, remote installs etc).
Firstly, you will need to identify the name of the Windows Feature that you wish to add / remove. Open an Administrative powershell prompt and type:  get-windowsfeature
Get-Windowsfeature
Get-Windowsfeature
Once you have identified the roles and feature that you wish to remove (in this case we are going to remove the gui shell) tye the command uninstall-windowsfeature If you want to force a reboot at the end of the process then use the -reboot switch.
Uninstall-windowsfeature
Uninstall-windowsfeature
If you wanted to re install this feature, or install any other feature then again open an administrative powershell prompt and type install-windowsfeature
Install-WindowsFeature
Install-WindowsFeature
Again, if you wanted to force the reboot (especially useful when scripting this then add the -reboot switch.







Tuesday, February 25, 2014

Bulk Reset User Passwords with Powershell.

Bulk Reset User Passwords with Powershell.

On occasion, you need to bulk reset user passwords for an ou or group of users. This  can easily be accomplished using Powershell and the following script.
Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Department,OU=Users,DC=corp,DC=company,DC=com" | Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "New Password Here" -Force)
Bulk Reset AD Passwords
Bulk Reset AD Passwords
Change the OU path to what you need it to be, and before you proceed you probably want to check the affected users with this script to ensure that you dont overwite something like the CEO or an admins password:
Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=Department,OU=Users,DC=corp,DC=company,DC=com"  | Ft Name 
Check OU Membership With Powershell
Check OU Membership With Powershell
Again, just change the OU structure to what you need.
As a point of note, you run this, depending on what you ahve installed you may need to  import the Active Directory Module for Powershell with Import-Module ActiveDirectory
Import-Module ActiveDirectory
Import-Module ActiveDirectory
This article can be viewed on our sister site www.dizzyit.com at: http://wp.me/p1Zlmi-7k

Manual Sync ADFS with Powershell.

Manual Sync ADFS with Powershell.

Occasionally you cant wait three hours for your ADFS to synchronise your local Active Directory with the Azure copy. No matter, as you can force a directory sync with the following powershell command:
Start-onlinecoexistencesync
start-onlinecoexistencesync www.dizzyit.com
start-onlinecoexistencesync www.dizzyit.com
This command will sync your on premises Active Directory with the Azure online copy. This is especially useful in situations such as Office 365 implementations where you have changes such as email addresses or group membership changes that need to be updated into the online directory.

This post can be viewed on our sister site www.dizzyit.com at: http://wp.me/p1Zlmi-7e




Friday, April 12, 2013

How to Install Features and Roles using PowerShell in Server 2012 and 2008

How to Install Features and Roles using PowerShell in Server 2012 and 2008


Server 2012 allows you to install features and roles via PowerShell. Before doing this, you may need to load the Server Manager Module with the command Import-Module Servermanager .








Firstly, you need to know the name of the windows feature / role that you wish to install. To find this information you enter the command Get-WindowsFeature . This will list the features available to install.



Server 2012

To install a feature or Role on a local machine, open PowerShell and type: install-windowsfeature {featurename} using the feature name you previously identified.







 Often this will require a restart,so you can add the -restart switch to the end of the command if you wish. It is also possible to install a feature on a remote machine using PowerShell by adding the -computername switch to the above command.

Server 2008

In Server 2008, the command to install is a little different to the above, but the switches are the same. The command used to install is add-WindowsFeature {featurename}  .


This Article can also be viewed on or sister site DizzyIT.com at http://dizzyit.com/2013/04/13/install-features-roles-powershell-server-2012-2008/

Monday, March 4, 2013

PowerShell - Set Execution Policy - Files Could not be Loaded because the running of scripts is disabled on this system.

PowerShell - Set Execution Policy -  Files Could not be Loaded because the running of scripts is disabled on this system.


when using PowerShell you may get an error stating that " Files Could not be Loaded because the running of scripts is disabled on this system. Please provide a valid certificate with which to sign the files" as shown below:



This at a basic level means that your security settings in PowerShell are preventing you from running the script ( the execution policy.

To fix this, you need to set the execution policy to a more relaxed setting. these are as follows:

  • Restricted - No Scripts can be run. Windows PowerShell can only be used in interactive mode.
  • All Signed - Only Scripts signed by a trusted publisher can be run
  • RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run
  • Unrestricted - No Restrictions, any PowerShell script can be run
At the time of writing, PowerShell comes out of the box in restricted mode.

To check which execution policy your system is running type Get-ExecutionPolicy




To change to policy you type Set-Execution Policy . When you run and go to a less secure setting, you will get a large warning asking if you want to do so
e.g. Set-ExecutionPolicy RemoteSigned.




It's not recommended to use unsigned as this would allow anyone who accesses the system to run malicious or damaging code on your system. Most individuals will settle on Remote Signed, however before doing so in an organisation please ensure that this complies with your organisations security settings.

for a video walk through of this, please check this youtube video from our sister site www.dizzyit.com . The article can also be located there.




Friday, January 25, 2013

Using Powershell to get export of AD users


Using Powershell to get export of AD users


Firstly, you need to import the Power Shell  command tools for AD

import-module activedirectory

Once this has been done, then run this command:

Get-ADUser -filter * -searchbase "OU=blah,OU=blah, ,DC=contoso,DC=microsoft,DC=com" -Properties given
Name, sn, sAMAccountname | select-object givenName,sn,samaccountname,distinguishedname | export-csv accountnames.csv

You can edit this for different results as required.