I referred to several examples I was able to search, which seemed highly pertinent, but am still unable to get this to work.
My input looks like this, from a dhcp server stats command, and I've confirmed that $output is getting defined properly with lines that look like:
MIBCounts:
Discovers = 63911.
Offers = 3903.
Delayed Offers = 0.
Requests = 29199.
Acks = 273080.
Naks = 71.
Declines = 0.
Releases = 395.
ServerStartTime = Tuesday, March 27, 2012 7:38:53 PM
Scopes = 34.
Scopes with Delay configured= 0.
Subnet = 10.31.0.0.
No. of Addresses in use = 203.
No. of free Addresses = 40774.
No. of pending offers = 0.
Subnet = 10.32.3.0.
No. of Addresses in use = 0.
No. of free Addresses = 0.
No. of pending offers = 0.
Subnet = 10.32.100.0.
No. of Addresses in use = 48.
No. of free Addresses = 145.
No. of pending offers = 0.
Subnet = 10.32.101.0.
No. of Addresses in use = 34.
No. of free Addresses = 159.
No. of pending offers = 0.
So what I tried was this, but got no matches:
$output=$(netsh -r myserver dhcp server show mibinfo)
$dhcp_regex=@"
(?s)Subnet = (\d\.\d\.\d\.\d)\.\W+
.*No\. of Addresses in use = (\d+)\.\W+
.*No\. of free Addresses = (\d+)\.\W+
"@
$dhcp_record= {
@{
subnet=$matches[0]
inuse=$matches[1]
free=$matches[2]
}}
$output -match $dhcp_regex
$matches
Assistance appreciated.