-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathGet-InstallDate.ps1
52 lines (47 loc) · 1.77 KB
/
Get-InstallDate.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<#
.Synopsis
Find the Installation date of Windows
.DESCRIPTION
Waht is the windows install date of the operating system for the target computer.
.EXAMPLE
Get-InstallDate
installDate ComputerName
----------- ------------
16/12/2013 11:48:21 TECH-01
.EXAMPLE
Get-InstallDate -ComputerName Hyper-A
installDate ComputerName
----------- ------------
17/02/2014 12:53:53 HYPER-A
#>
function Get-InstallDate
{
[CmdletBinding()]
Param
(
# Target Computer
[Parameter(ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]
$ComputerName = 'localhost'
)
Begin
{
}
Process
{
Get-WmiObject win32_OperatingSystem -ComputerName $ComputerName |
select @(
@{name='installDate';expression={
[Management.ManagementDateTimeConverter]::ToDateTime($psItem.installDate)}
}
@{name='ComputerName';expression={$psItem.CSName} }
)
# Win 8.1, R2 and WMF 4.0 Only. Won't be using get-CimInstance for a while
# Get-CimInstance win32_operatingsystem | select installDate
}
End
{
}
}