Script

Best Practices for Signing a Windows PowerShell Script

by File in: Script

There are a lot of benefits of using Windows PowerShell over the more popular Command Prompt. But using PowerShell without digitally signing scripts can leave you vulnerable to attacks. This post will explain the importance of PowerShell script signatures and mention some best practices so your scripts remain secure. What is Windows PowerShell? Windows PowerShell […]

How to Use the Microsoft Anti-Malware Script Interface

by File in: Script

Hackers are increasing the malware attacks executed in memory. One of the main execution methodologies for in memory attacks is to execute a script directly without ever writing to disk.  Traditional anti-virus works by comparing signatures to files on disk. But what do we do when the executing code never touches the disk? Or worse, […]

Desired State Configuration in PowerShell

by File in: Script

Hello everybody and welcome to a new and cool article about PowerShell. This time we’ll learn how to implement DSC by using PowerShell. DSC is basically Configuration as Code, where we configure certain aspects of a system by using some type of manifest, or better yet a configuration file. DSC is the PowerShell alternative to […]

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 […]