A really neat new feature in 2012R2 is that Hyper-V can resize a running virtual machine (.vhdx) to the smallest possible size, while the virtual machine is running. To do so, use Get-VM in PowerShell. Here, we’ll use the -Path option to define the location of our vhdx, the -ToMinimumSize option to indicate that we’d like to shrink it down as low as we can go and -AsJob so it runs in the background: Resize-VHD –Path D:\myVM.vhdx –ToMinimumSize -AsJob
-
-
Configure Exchange Mailbox Database Maintenance Schedules
Exchange databases need maintenance. This maintenance defragments the databases, reindexes the databases and performs other tasks necessary for long-term sustainability of the databases. To configure maintenance, open the Exchange Management Console and then under Organization Configuration select Mailbox. At the Database Management tab, double-click on the database to schedule maintenance for and click on the Maintenance tab. Here, check the box for Enable background maintenance and then select one of the schedules for which Exchange maintenance occurs. This schedules a nightly database maintenance window where Exchange Server can perform the necessary operations on a given database. Alternatively, if you have a lot of databases or need to batch change these…
-
Rename a Windows 2012 Server Using PowerShell
When you are creating a bunch of Server 2012 Virtual Machines (or physical machines for that matter) it is helpful to programmatically change their names. To do so, use the Rename-Computer PowerShell cmdlet followed by the name you want the computer to have, as follows (assuming a name of 2012.krypted.com): Rename-Computer 2012.krypted.com Before you do anything else (e.g. bind to AD) you should then reboot the host, using the Restart-Computer cmdlet: Restart-Computer
-
Creating Users On Windows Server 2012 Using PowerShell
Scripting user creation in Windows Server is something we’ve long done using LDIF files; however, when building a system that creates users in more of a one-off capacity it’s pretty easy to script the creation process using PowerShell, piping information in from other solutions. To create a user, use the New-ADUser cmdlet. I’ve found that we usually need to populate this with a few pieces of information, including the account name (SamAccountName), the password (AccountPassword), the full name (name) enabling the account (enabled), setting the password not to expire (PasswordNeverExpires) and forcing the user to change their password when they log on (ChangePasswordAtLogon). Respectively, the following example would create user…
-
Create Mail Contacts On Exchange 2013 Using PowerShell
Exchange 2013 allows administrators to script Mail Contact creation and email enable those contacts. Let’s say you want to create a contact named Charles Edge and configure an External Email Address of cedge@318.com and set the Organization Unit to Enginnering. Well, that would look something a little like this: New-MailContact -Name "Charles Edge" -ExternalEmailAddress "cedge@318.com" -OrganizationalUnit "Engineering" And if you’ve never spent much time in Minnesota, the acronym for Database Availability Group is DAG. Just pronounce the A with an AE sound about 20 times and you’ll understand how awesome it can be. 🙂
-
Setting Up Active Directory In Windows Server 2012
Installing Active Directory services is arguably one of the first things done on many a Windows Server. And for well over a decade you could unbox, update, run dcpromo and be done with much of that. While the wizards are still there, in the case of Windows Server 2012, the process has changed ever-so-slightly. To install a domain controller in Windows Server 2012, start with Server Manager. This new tool is the place where you start many a process in a Windows Server now, and Active Directory is no different. To get started, first open Server Manager. From Server Manager, click on the Manage menu and select Add Roles and…
-
Managing Windows Server 2012 Shares From Powershell
SMB cmdlets come in two modules. Before you can really use these in powershell you first need to import them. These are called SmbShare and SmbWitness, so to import the modules: Import-Module SmbShare Import-Module SmbWitness Or for short: Import-Module Smb* Once the SMB modules are imported, we’ll start by looking at what shares you’ve got on your system using Get-SmbShare: Get-SmbShare Next, we can create a new share with the minimum two pieces of information required and adding who get’s FullAccess, which is not required: New-SmbShare -Name BAK -Path E:BAK -FullAccess krypted Then we can provide a little more information if we so choose. Here, I’m going to add a…
-
Managing Office 365 Users Using PowerShell
Programmatically controlling the cloud is an important part of trying to reign in the chaos of disparate tools that the beancounters make us use these days. Of all the companies out there, Microsoft seems to understand this about as well as anyone and their fine programmers have provided us with a nice set of tools to manage Office 365 accounts, both in a browser (as with most cloud services) and in a shell (which is what we’ll talk about in this article). This article isn’t really about scripting PowerShell. Instead we’re just looking at a workflow that could be used to script a Student Information System, HRIS solution or another…
-
Powershell Goodies From Vexasoft
There are a number of features that make mass deployment of Mac OS X pretty easy. Some of these would be great to have in Windows. These range from systemconfiguration to networksetup and the ability to look at packages that have been installed and review their bills of material. Well, the good people at Vexasoft have built a number of Powershell libraries that, while they aren’t named as such, do a number of the features that these commands do, just for Windows clients via Powershell. And the best part is, a number of them are free. Let’s look at what some of these commands do: First, there are the cmdlets…