Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
4.2 kB
2
Indexable
Never
#Load 
$machines = @("isrv00293","isrv00107","isrv00105","isrv00103","isrv00104","isrv009xx", "isrv00106", "isrv00xx")

"`n"
write-Host "Server Online Status"
$servers = $machines | ForEach-Object {
    [PSCustomObject]@{
        Machine = $_
        State    = if (Test-Connection -BufferSize 32 -Count 1 -ComputerName $_ -Quiet) {
            $true
        } else {
            $false
        }
    }
}

$serversexp = $servers | Select Machine, State 
$serversexp  
$serversexp | ConvertTo-Json | Out-File "C:\inetpub\wwwroot\dashboard\json\servers.json"


"`n"
write-Host "HTTP Bindings"
 
   $httpbindings = foreach ($machine in $machines ) {
        icm -comp $machine { param($machine) 
        import-module webadministration;
        $webbinding = Get-WebBinding -Name "Default Web Site" -Protocol "https"
            if ($webbinding){
               [PSCustomObject]@{ Machine = $env:COMPUTERNAME; State = $true; }
            }
            else{
                [PSCustomObject]@{ Machine = $env:COMPUTERNAME; State = $false; }
                
            }
    }-ArgumentList $machine  -ErrorAction SilentlyContinue

   
} 
$httpexport = $httpbindings | Select Machine, State 
$httpexport
$httpexport | ConvertTo-Json | Out-File "C:\inetpub\wwwroot\dashboard\json\httpscheck.json"



"`n"
write-Host "Check Certificate Expiration Date"
$certs = foreach ($machine in $machines ) {
    icm -comp $machine {

        $cert = Get-ChildItem Cert:\LocalMachine\My
        if ($cert) {
            [PSCustomObject]@{
                Machine      = $env:COMPUTERNAME
                FriendlyName = $cert.FriendlyName
                NotAfter     = $cert.NotAfter
                NotBefore    = $cert.NotBefore
                State        = if ($cert.NotAfter -lt (Get-Date)) {
                    "expired"
                } else {
                    $cert.NotAfter.ToString('dd/MM/yyyy')
                }
            }
        } else {
            [PSCustomObject]@{
                Machine      = $env:COMPUTERNAME
                FriendlyName = ''
                NotAfter     = ''
                NotBefore    = ''
                State        = $false
            }
        }
    } -ErrorAction SilentlyContinue
} 
$certexport = $certs | Select Machine, State
$certexport | ConvertTo-Json | Out-File "C:\inetpub\wwwroot\dashboard\json\certexpirationdate.json"
$certexport



"`n"
write-Host "Check for iisrole"
 
   $iis= foreach ($machine in $machines ) {
        icm -comp $machine { param($machine) 
        import-module webadministration;
        $iisisinstalled = Get-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole                             
     
            if ($iisisinstalled){
               [PSCustomObject]@{ Machine = $env:COMPUTERNAME; State = $true }
            }
            else{
                [PSCustomObject]@{ Machine = $env:COMPUTERNAME; State = $false }
                
            }
    }-ArgumentList $machine  -ErrorAction SilentlyContinue

   
} 
$iisexp = $iis | Select Machine, State 
$iisexp | ConvertTo-Json | Out-File "C:\inetpub\wwwroot\dashboard\json\iisinstalled.json"
$iisexp

"`n"
write-Host "Check for .net"
 
   $netinstalled= foreach ($machine in $machines ) {
        icm -comp $machine { param($machine) 
        import-module webadministration;
        $netisinstalled = Get-WindowsOptionalFeature -Online -FeatureName NetFx3ServerFeatures    
            if ($netisinstalled){
               [PSCustomObject]@{ 

                Machine = $env:COMPUTERNAME; 
                State = $true 

               }
            }
            else{
                [PSCustomObject]@{ 
                    Machine = $env:COMPUTERNAME; 
                    State = $false }
                
            }
    }-ArgumentList $machine  -ErrorAction SilentlyContinue

   
} 
$netexport = $netinstalled | Select Machine, State 
$netexport | ConvertTo-Json | Out-File "C:\inetpub\wwwroot\dashboard\json\netinstalled.json"
$netexport
$netexportbykey = $netexport | Select Machine
$netexportb