PowershellModules/LAPS/LAPS.psm1

62 lines
1.7 KiB
PowerShell
Raw Normal View History

2022-02-07 10:33:53 +01:00
 <#
.SYNOPSIS
Read laps passwort and exiration date from active directory
.DESCRIOTION
Read laps passwort and exiration date from active directory. You can pipe hostnames as input or define as parameter.
.INPUTS
Pipe names from array or as result from Get-AdComputer
.OUTPUTS
Return PSCutomObject with Fields DNSHostName,ms-Mcs-AdmPwd,ms-Mcs-AdmPwdExpirationTime
.EXAMPLE
PS> Get-ADLaps hostname
DNSHostName ms-Mcs-AdmPwd ms-Mcs-AdmPwdExpirationTime
----------- ------------- ---------------------------
hostname 47h4(44E 19.02.2022 09:28:15
.EXAMPLE
PS> hostname | Get-ADLaps
DNSHostName ms-Mcs-AdmPwd ms-Mcs-AdmPwdExpirationTime
----------- ------------- ---------------------------
hostname 47h4(44E 19.02.2022 09:28:15
.EXAMPLE
PS> Get-ADComputer hostname | Get-ADLaps
DNSHostName ms-Mcs-AdmPwd ms-Mcs-AdmPwdExpirationTime
----------- ------------- ---------------------------
hostname 47h4(44E 19.02.2022 09:28:15
#>
function Get-ADLaps{
[CmdletBinding(DefaultParameterSetName="Identity")]
param(
[Parameter(Mandatory = $true,
ParameterSetName="Identity",
Position = 0,
ValueFromPipeline = $true
)]
[string[]]$Identity
)
BEGIN{}
PROCESS{
foreach ($i in $Identity)
{
Get-ADComputer $i -Properties ms-Mcs-AdmPwd, ms-Mcs-AdmPwdExpirationTime | Select-Object DNSHostName,ms-Mcs-AdmPwd,@{name="ms-Mcs-AdmPwdExpirationTime";Expression={[datetime]::FromFileTime($_."ms-Mcs-AdmPwdExpirationTime")}}
}
}
END{}
}
Export-ModuleMember -Function Get-ADLaps