Tag Archive for 'Scripting'

Pull DHCP info using PowerShell

This short script will get all the DHCP servers authorized in your Windows domain, and pull all the scopes and IPs. It exports these to two separate CSV files. $DHCPServers = Get-DhcpServerInDC If (Test-Path -Path $env:TEMP\Scopes.csv) {Remove-Item $env:TEMP\Scopes.csv} If (Test-Path -Path $env:TEMP\Leases.csv) {Remove-Item $env:TEMP\Leases.csv} If (Test-Path -Path $env:TEMP\Leases.csv) {Remove-Item $env:TEMP\DNSExport.csv} foreach ($_ In $DHCPServers) { […]

Express Route Provisioning Error

  We have recently decided to invest in an Express Route circuit for Azure.  It is supposed to be helpful with Azure and Office 365.  There are two ways to provision the ExpressRoute circuit.  Both require PowerShell. There is the classic: https://azure.microsoft.com/en-us/documentation/articles/expressroute-howto-circuit-classic/ And there is the Resource Manager: https://azure.microsoft.com/en-us/documentation/articles/expressroute-howto-circuit-arm/ Here is the note about those […]

SharePoint Documents are all checked out

I wanted to write a PowerShell script to check all the documents back in that had been checked out.  Turns out that is not as straight forward as I had hoped. First search came up with this: Office Discarding Check Out Using PowerShell Then when I tried to run the command (from the server console, […]

Operations Manager 2012 R2 Management Pack Dependencies

I am not proficient at managing Ops Manager.  I am at best a competent tinkerer.  I have been needing to do some clean up on our Ops Manager installation, and clear some management packs that are not used, or just used to generate noise that we subsequently ignore.  That is a bit of an annoying […]

Script to fix “unknown” power state in Xen Desktop

  After an unpretty Hyper-V cluster failover, several machines in our Xen Desktop deployment were showing an “unknown” power state.  After a call to Citrix, they gave my coworker a few commands to use to fix it. This has to be done from the Xen Desktop controller: Load the Citrix PSSnapIn: Add-PSSnapIn Citrix.* This gets […]

Launch a PowerShell script minimized

We use Citrix for a lot of applications, and I have a need to launch Outlook, then an application, and then close Outlook when that application is closed by the user.  This seems like a pretty simple thing to do (and I suppose it is, sort of) but it took me a while to figure […]

Using Powershell to get logon script path from Active Directory

If you want to know what logon script users are getting, this is an easy way to get that information: Import-Module -Name ActiveDirectory Get-ADUser -Filter * -SearchBase "OU=YourOUName,DC=YourDomain,DC=COM" -properties ScriptPath | Export-Csv "c:\script\ADUser.csv" Note: In order for this to work, you have to have the ActiveDirectory Module loaded. 

Not recognized as a cmdlet…

I have been working on a simple little script to copy a file and then launch a program.  I am sure that there are a lot of ways to do it, but I decided to use PowerShell, and this is what I came up with: $CheckForFile = "H:\custom.ini" $FileToCopy = "c:\IT\custom.ini" $CopyFileTo = "H:\" $PathTest […]

PowerShell Confirm Preference

I seem to run into an issue when I run some PowerShell scripts where I get prompted at each line of the script for confirmation.  That can get really annoying, so I have to look up how to prevent that behavior.  Thankfully, there is already some good information out there on how to do that: […]

Servers in Domain

At some point, I had a desire to list all the computer accounts for any server OS in Active Directory.  I am pretty sure that I did a search and found the script below, but I don’t remember where, so whoever wrote it doesn’t get credit this time… $strCategory = “computer” $strOperatingSystem = “Windows*Server*” $objDomain […]