Functions/Get-DsRegStatus.ps1

function Get-DsRegStatus {
    <#
    .Synopsis
    Returns the output of dsregcmd /status as a PSObject.
 
    .Description
    Returns the output of dsregcmd /status as a PSObject. All returned values are accessible by their property name.
 
    .Example
    # Displays a full output of dsregcmd / status.
    Get-DsRegStatus
    #>

    if(-not (Get-IsAdmin)){
         throw "Access Denied: The cmdlet needs to be executed with administrator priviledges."
    }
    $dsregcmd = dsregcmd /status
    $o = New-Object -TypeName PSObject
    $dsregcmd | Select-String -Pattern " *[A-z]+ : [A-z]+ *" | ForEach-Object {
              Add-Member -InputObject $o -MemberType NoteProperty -Name (([String]$_).Trim() -split " : ")[0] -Value (([String]$_).Trim() -split " : ")[1]
         }
    return $o
}
# SIG # Begin signature block
# MIINHQYJKoZIhvcNAQcCoIINDjCCDQoCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUny5FvB9L0bj6tbWbTOUxByxg
# z6mgggpfMIIFJzCCBA+gAwIBAgIQCU9NEi6qCZCLwI+uzRfDqjANBgkqhkiG9w0B
# AQsFADByMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD
# VQQLExB3d3cuZGlnaWNlcnQuY29tMTEwLwYDVQQDEyhEaWdpQ2VydCBTSEEyIEFz
# c3VyZWQgSUQgQ29kZSBTaWduaW5nIENBMB4XDTE2MDYwNjAwMDAwMFoXDTE5MDYx
# MTEyMDAwMFowZDELMAkGA1UEBhMCQ0gxEjAQBgNVBAgTCVNvbG90aHVybjERMA8G
# A1UEBwwIRMOkbmlrZW4xFjAUBgNVBAoTDWJhc2VWSVNJT04gQUcxFjAUBgNVBAMT
# DWJhc2VWSVNJT04gQUcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCf
# mKY1pgRieuq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