Tag Archive for 'PowerShell'
February 27th, 2018 by Michael
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) { […]
February 27th, 2018 by Michael
This is a “one liner” that pulls all the DNS Entries for a particular zone, including the IPv4 and IPv6. If you don’t care about the IPv6, you can remove that segment of the code. Get-DnsServerResourceRecord –ComputerName <DNSServerName> –ZoneName <YourZoneName> | Select-Object DistinguishedName,HostName,@{Name=’IPv4Address’;Expression={$_.RecordData.IPv4Address.IPAddressToString}},@{Name=’IPv6Address’;Expression={$_.RecordData.IPv6Address.IPAddressToString}},RecordType,Timestamp,TimeToLive | Export-Csv $env:TEMP\DNSExport.csv –NoTypeInformation It is amazing how much you can do […]
June 5th, 2015 by Michael
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, […]
May 18th, 2015 by Michael
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 […]
August 27th, 2012 by Michael
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 […]
December 28th, 2011 by Michael
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 […]
July 29th, 2010 by Michael
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.
March 25th, 2010 by Michael
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 […]
March 4th, 2010 by Michael
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: […]
February 24th, 2010 by Michael
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 […]