I was recently asked to build a Powershell script to fully automate building up a server, including detailed configuration and installation of roles and other software.
Some of these actions required a reboot. After a reboot, the Powershell script had to restart itself. When running a script remotely, Workflows can be used, but when running the script locally I could not get this to work properly. Thus, I built a self-restarting script template that will run each phase as you configure it.
This self-resuming Powershell script writes its own run configuration to a Scheduled task that will run at boot time without user interaction, under the SYSTEM account. It will run all the commands you specify, reboot and resume when necessary, and unregister itself when it has completed.
This is awesome for, for example, building up Terminal Servers or Web Servers in a highly virtualized environment. Of course there are many orchestration tools available, and they may be better suited for this task, but those were not available when I was asked to code this.
Download it here: AutoBuilder_v0.3
Or check out the source code:
Continue reading AutoBuilder, a self restarting Powershell script for orchestration
If you’ve been administering or enrolling tenants for Office 365, you’ve dealt with Licenses.
In Office 365 (or Azure and Intune!), various licensing plans are available and can be upgraded or downgraded at will quite flexibly.
However, the user interface for this is extremely limited when you start working with large numbers of users or start working with non O365 specific licenses such as EMS and there is no place or method to keep an amdministration or rulebase of who should have what license.
I’m writing a series of scripts to bulk automate user licensing in Continue reading Office 365 automated license management part 1
For a global customer with terrabytes of Exchange 2013 data, I recently wrote a multi-threading powershell script I’d like to share with everyone.
The use case was an integrity check of the database backups prior to Exchange maintenance. First we have to commit all log files to a large number of databases, then run a surface or deep check on these databases before we can be relatively sure a restore won’t fail. Continue reading Multi-Threading Powershell script to Check and Repair numerous Exchange databases
Due to popular request, I’ve added an analyze function to the O365Uploader. After choosing your folder to be uploaded, a popup will ask you if you wish to see an analysis of potential issues and suggested fixes for your content. Everthing will both be written to the Powershell console in the background and a detailed log file which can be used in MS Excel.
You can download the new version here.
- Added check for period in folder/file name
- Added check for various illegal suffixes in filenames
- Added verification prompt before upload to log all issues to a file beforehand so it can be fixed in advance
- Added warning for 5000+ items
- Added warning for hidden files (start with an _ )
For anyone in need of a nice and easy to use tool that helps you migrate your folders to Office 365 or OneDrive, check out my Office 365 Uploader.
The tool is totally free, I provide no warranty or dedicated support, use at your own risk.
Sometimes you want to be able to just double click your powershell scripts and see them work….putting this code at the top of your script will do just that by detecting if the script is running as administrator with administrative priviledges. If not, the script will launch a new instance of itself with an elevation prompt.
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
For a certain application, a locally installed FTP server was required. Scripting this seemed easy, and plenty of examples could be found but none worked properly. So I’m sharing my method with you. Below code installs FTP. The final 3 lines enable anonymous authentication and create a Default FTP site that points to c:\temp
Hope it helps someone! Do note the reboot is actually mandatory.
dism.exe /Online /Enable-Feature /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication
%windir%\system32\inetsrv\AppCmd set config -section:system.applicationHost/sites /siteDefaults.ftpServer.security.authentication.anonymousAuthentication.enabled:"True" /commit:apphost
%windir%\system32\inetsrv\AppCmd add site /name:"Default FTP Site" /bindings:ftp://localhost:21 /physicalpath:c:\temp\
%windir%\system32\inetsrv\AppCmd ADD vdir /app.name:"Default FTP Site/" /physicalpath:c:\temp