PowerShell Functions: Get IPV4 Network Start and End Address

I wrote 2 PowerShell functions today: Get-IPV4NetworkStartIP and Get-IPV4NetworkEndIP. Input: Network IP address in CIDR notation Format Output: The start or end IP (System.Net.IPAddress object). Get-IPV4NetworkStartIP: Get-IPV4NetworkEndIP: Usage: Get-IPV4NetworkStartIP “192.168.1.0/24” Get-IPV4NetworkEndIP “192.168.1.0/24” Examples:

Continue reading

Updated: SCCM Health Check PowerShell Script

I have updated the SCCM Health Check Script that I have originally posted here. Download Version 3.1 Here. Changes: 1. The script can now utilise Powershell Remoting to check inboxes sizes. It requires PS-Remoting to be enabled on all SCCM Site Servers. This dramatically reduced the execution time of the script in a multi-tier environment. In a production environment that I support, it reduced the execution time from 1.5 – 2 hours to around 35 minutes!  You can configure which method to use via XML file. To enable, set <PSRemoting><Value> to Enabled. Or Disabled if you want to use the

Continue reading

Problem with DNS name resolution when using System.Net.DNS class

I recently ran into a problem when writing a PowerShell script to perform DNS Name resolution using .NET class System.Net.DNS (http://msdn.microsoft.com/en-us/library/system.net.dns.aspx). I noticed when I’m using System.Net.DNS to perform reverse lookup (GetHostByAddress method), even though the PTR record is missing in DNS, it is still able to resolve the name. It looks like this method connects to the host to retrieve its host name. When the machine is powered off, GetHostByAddress method is unable to resolve the IP address to it’s name (Which is desired result because there is no PTR record in reverse lookup zone): I then powered on

Continue reading

PowerShell Script: SCCM Health Check

30/01/2012: This script has been updated to version 3.5. Details can be found HERE. The download link on this article has also been updated to version 3.5. 26/05/2011: Version 3.3 has been posted here. The download link to the script on this post is also updated to the new version 3.3. 21/04/2011: Please be advised that I have posted a newer version of the script here. The existing script download link on this page has also been updated to point to the newer version. For the chanages in newer version, please refer to my updated post. Over the last few

Continue reading

Powershell Functions do not return single element arrays

I came across an interesting problem today that a function I wrote to return all SCCM primary sites worked at work but did not work at home. the difference between 2 SCCM environments is that I only have 1 single SCCM site in my home environment comparing to large multi-tier SCCM infrastructure at work. after some investigation I found out this common issue with Powershell when comes to returning arrays from a function. For example: The first function foo should returns a single element arraylist, and the variable it returned has the same type as the type of the only

Continue reading

How to locate SCCM Collection Object based on the Collection ID

Often, I found it’s hard to locate the Collection object in the SCCM console if you only know the Collection ID. Couple of weeks ago I ran into a situation where I need to modify the settings of a bunch of collection objects and all I knew was the Collection ID. I wrote a script called Get-CollectionPath that identifies all possible paths to a particular collection (as a collection can be linked to multiple places). The Syntax is: .\Get-CollectionPath <SCCM Central Site Server Name> <Collection ID> Download the script here.

Continue reading

Hyper-V virtual machines with “Missing” status

I’m currently running Hyper-V R2 on a machine with 24GB of memory at home. It hosts most of my test machines such as SCCM, SCOM, Exchange, etc. System Center Virtual Machine Manager 2008 R2 (VMM) is installed on a separate box to manage this Hyper-V Host. Few days ago the Hyper-V machine was powered off unexpectly and when it powered back online, in VMM, the status of 2 virtual machines showed as “Missing”. I checked the location where virtual machines are stored and without doubt, the vhd, xml and other files for each virtual machine are still there. I Checked

Continue reading

Incorrect description in SCCM Report License 03B – Computers with a specific license status (Report ID 350)

On the SCCM Report “License 03B – Computers with a specific license status” (Report ID 350, category Asset Intelligence), the description states there are 5 possible values for license status: This is incorrect. SCCM collects licensing data from client’s WMI class SoftwareLicensingProduct in root\cimv2 namespace and regarding to below MSDN article, there are 7 possible values for LicenseStatus: http://msdn.microsoft.com/en-us/library/cc534596(VS.85).aspx Below is an example of a server with license status 5 showing up in the SCCM report:

Continue reading

Failed to run PowerShell script via Task Scheduler on a 64 bit Windows

I came across a situation the other day that on a Windows Server 2008 R2 box, when I created a Scheduled Task to run a Powershell script, it runs OK using “C:\Windows\System32\WindowsPowerShell\v1.0\Powershell.exe” (64 bit PowerShell) but fails with error code (0x1) if I use “C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Powershell.exe” (32 bit Powershell) I have done the following steps to help me troubleshoot the issue. 1. I have changed the scheduled task to “Run only when user is logged on” so a command prompt was shown when the task runs. I screen captured the output: It looks like the PowerShell Execution Policy is preventing the

Continue reading
%d bloggers like this: