Script

Windows Azure Script – Create a New VM from an Existing VHD

by File in: Script

Hello and welcome to another tutorial on using PowerShell with Azure in order to create a new Virtual Machine resource from an existing VHD. From time to time, we might need to copy a Virtual Machine environment from our Hyper-V environment to Azure and create a new VM Instance. To complete this task we will […]

Office 365 Tenant – Get All Users List Script

by File in: Script

In this article I will present to you a small script that lets us get a list of all  users from a specific Office 365 Tenant. The Script: Import-Module AzureAutomationAuthoringToolkit $username = “migadm@titanbuckle.com” $password = ConvertTo-SecureString “Muva9659” -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential($username, $password) Connect-MsolService -Credential $creds $users = Get-MsolUser ForEach ($user in $users) { […]

Counting the Number of Files in a Directory, Command Line Style

by File in: Script

Recently, I needed to count the number of files in a directory on a Windows server. Here’s the command that can easily be scripted. It can also be used on Windows client machines running Windows 10, etc. dir/b/a-d c:\directory | find /v /c “::” You can also specify a file share instead of a directory name: […]

Script to Remotely List Windows Local Administrator Group Membership

by File in: Script

The following script can be run against remote Windows machines, and will enumerate the contents of the remote server’s local administrators group. It requires Sysinternals PSExec utility, and must be run with administrative credentials.  Set the four paths to the correct locations for your workstation. REM set path to PSexec on machine the script is […]

Powershell Script to Change from Static to Dynamic IP Addressing

by File in: Script

I’ve been working on validating an email server migration plan which has required utilizing test servers isolated from the production network.  Because they are offnet, I have to frequently switch my laptop from the production to test networks, which involves reconfiguring my network card from dynamic to static IP addresses. I could use Windows XP’s […]

Script to Gracefully Close an Outlook .PST File So It Can Be Backed Up

by File in: Script

I was listening to the latest episode of the Casting from the Server Room podcast this morning, and one of the discussions was about backing up an Outlook .pst when users leave Outlook open overnight, which is when the backup is scheduled to run. In order to back an Outlook .pst file, the .pst file must […]

Script to Backup the Windows Server System State using NTbackup from the Command Line

by File in: Script

Here’s a simple batch file script to backup the Windows Server 2003 System State to a removable drive: for /f “Tokens=1-4 Delims=/ ” %%i in (‘date /t’) do set dt=%%i-%%j-%%k-%%l for /f “Tokens=1” %%i in (‘time /t’) do set tm=-%%i set tm=%tm::=-% set dtt=%dt%%tm% C:\WINDOWS\system32\ntbackup.exe backup systemstate /v:yes /r:no /rs:no /hc:off /m normal /j “server04 […]

HowTo: Automatically Remove Files Older Than ‘X’ Days

by File in: Script

Tape backups have failed me too many times, so I now do my Windows backup to an external hard drive. One of the office staff is in charge of swapping out our backup drives and taking it offsite. I needed a solution that would remove old backups without user intervention so they wouldn’t have to […]