• Windows Server

    Resize Hyper-V .vhdx To Minimum Size

    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

  • Microsoft Exchange Server,  Network Infrastructure,  Windows Server

    Delete Messages From Exchange Using PowerShell

    Before I type anything else, allow me to state that running a search and deleting things with a script from a users (or a loop of all users) is a very dangerous process. However, I’ve often noticed that an outbreak of bad things can cause us to do some pretty awesome things. So, you can use the get-Mailbox cmdlet to pipe a mailbox into the search-mailbox cmdlet and from there use the -SearchQuery option to search for an attachment, following the attachment option with a filename and then delete it using the -DeleteContent option. The example would be as follows: Get-Mailbox -Identity “cedge” | Search-Mailbox -SearchQuery attachment:ichatsmileys.pkg.zip -DeleteContent You can…

  • Microsoft Exchange Server

    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…

  • Active Directory,  Windows Server

    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

  • Microsoft Exchange Server

    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. 🙂

  • Active Directory,  Windows Server

    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…

  • Uncategorized

    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…

  • cloud,  Microsoft Exchange Server,  Windows Server

    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…

  • Mass Deployment,  Windows Server,  Windows XP

    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…