locked
Need heyperlink in powershell output HTML RRS feed

  • Question

  • HI Team,

    In below the script is generating output in HTML format. which looks good but in here I tried to get the hyperlink in Action Tab & which will invoke the command corresponding to same machine for same app pool for which it is targeting.

    

    Script Details.


    Sumeet Gill

    $Header = @'
    <Title>App Pools Status</Title>
    <style>
       body { background-color:#E5E4E2;
           font-family:Monospace;
           font-size:10pt; }
    td, th { border:0px solid black; 
             border-collapse:collapse;
             white-space:pre; }
    th { color:white;
         background-color:black; }
    table, tr, td, th { padding: 2px; margin: 0px ;white-space:pre; }
    tr:nth-child(odd) {background-color: lightgray}
    table { width:95%;margin-left:5px; margin-bottom:20px;}
    h2 {
     font-family:Tahoma;
     color:#6D7B8D;
    }
    
    .footer 
    { color:green; 
      margin-left:10px; 
      font-family:Tahoma;
      font-size:8pt;
      font-style:italic;
    }
    
    </style>
    '@
    
    $sb = {
        Try{ 
            Import-Module WebAdministration -ErrorAction Stop
            Get-ChildItem IIS:\AppPools -ErrorAction Stop
            
        }
        catch{
        
            Write-Host $_ -ForegroundColor Green
        }
    } 
    
     Get-Content C:\WebSite\ServerBaseAppstatus\Machines.txt |
        ForEach-Object{
           Invoke-command  -ComputerName $_ -ScriptBlock $sb -ArgumentList $machine -ErrorAction SilentlyContinue
        } |
        Select-Object PsComputerName, name, State, ManagedRuntimeVersion, Action |
        ConvertTo-Html -Head $Header |
        Out-File -FilePath C:\WebSite\ServerBaseAppstatus\Machines.html


    • Edited by Sumeet Gill Monday, September 10, 2018 11:53 AM
    Monday, September 10, 2018 11:21 AM

All replies

  • Please post code correctly.  Use the code posting tool provided.

    What is an "action tab".

    There are no "hyperlinks" in ConvertTo-Html.  You will have to edit the HTML and add them


    \_(ツ)_/

    Monday, September 10, 2018 11:30 AM
  • Well.. In action tab I need any text which contain some invoke-command to start  the corresponding apppool. 

    Sumeet Gill

    Monday, September 10, 2018 11:47 AM
  • You cannot place commands into an HTML document.  HTML cannot execute PowerShell commands.

    I suggest using a form with a grid to have an active GUI.


    \_(ツ)_/

    Monday, September 10, 2018 11:57 AM