Link to home
Start Free TrialLog in
Avatar of brittonv
brittonvFlag for United States of America

asked on

Powershell Script to list all servers built within 7 days

I am looking for a powershell script that will list all VM's built the last 7 days.  

Is this possible?  If so how do I do it?
Avatar of soostibi
soostibi
Flag of Hungary image

What about this?
$WQL = "SELECT * FROM MSVM_ComputerSystem WHERE ProcessID >= 0"
$HyperVNamespace = "root\virtualization"
Get-WmiObject -NameSpace $HyperVNamespace -Query $WQL | 
    Select-Object elementname, @{n="install"; e={
        [DateTime]::ParseExact($_.installdate,"yyyyMMddHHmmss.000000-000", [System.Globalization.CultureInfo]::InvariantCulture)}} | 
            ?{((get-date)-$_.install).totaldays -gt 7 }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial