Page 1 of 1

une fonction pour ss64 - Query an XML feed

Posted: 2021-Jul-25, 9:59 am
by MigrationUser
07 Dec 2011 11:26
jumper


hi

a small gift for members of SS64 :)

Code: Select all

Function Get-ss64 {

<#
 .Example
  PS[1]> Get-ss64

DateTime               Author                 Title                  Online               
--------               ------                 -----                  -----                
07/12/2011 05:21:02    theretard              merge                  True              
07/12/2011 05:17:36    theretard              FORFILES help          False              
06/12/2011 15:06:22    theretard              avoiding loop          False              
06/12/2011 03:05:54    theretard              %CommonProgramFiles... False              
05/12/2011 20:02:05    theretard              get file location t... False              
      
...
...

.Example
 PS[2]> Get-ss64 -Today
 
DateTime               Author                 Title                  Online               
--------               ------                 -----                  -----                
07/12/2011 05:21:02    theretard              merge                  False              
07/12/2011 05:17:36    theretard              FORFILES help          False             


.Example
 PS[3]> get-ss64 | Where { $_.Author -eq 'user' } | select Title,DateTime 
 
.Example
 PS[4]> get-ss64 -invoke
 # open browser

.Example
 PS[5]> get-ss64 | Select -first 3

.INPUTS
none

.OUTPUTS
PSCUSTOMOBJECT

#>
 param([Switch]$Today,[Switch]$Invoke)
 End{
  try{
    $objTable = @()
    $objweb = New-Object net.webclient
    [Xml]$objXml = $objweb.DownloadString('https://ss64.org/extern.php?action=feed&type=atom')
     $objTable += $objXml.feed.entry | Select-Object -Property @{
          Name = 'DateTime'
          Expression = { $_.updated -as [datetime] }
       },@{
          Name = 'Author'
          Expression = { $_ | select -expand author | % { $_.name.'#cdata-section' } }
       },@{
          Name = 'Title'
          Expression = { $_ | select -expand FirstChild | % { $_.'#cdata-section' } }
      },@{
         Name = 'Online'
         Expression = { 
           $page = ''
           $objlink = New-Object net.webclient
           $link = $_ | select -Expand link | select -Expand href
           $page = $objlink.DownloadString($link)
           $page -match 'online'
           $objlink.Dispose()
           Remove-Variable objlink
         }
      }
      if($Today) { 
        $objTable | Where { $_.DateTime -eq (date)  }
      } else { $objTable }
      if($Invoke) {
        start $($objXml.feed.entry | select -expand link | % { $_.href })[0]
      } 
    }
  catch [System.Net.WebException] { return $_.exception.message }
  finally{ 
   $objweb.Dispose()
   }
 }
}

Re: une fonction pour ss64 - Query an XML feed

Posted: 2021-Aug-28, 11:31 am
by Simon Sheppard
n.b. as written this uses the feed for the old forum https://ss64.org/extern.php?action=feed&type=atom
While that should redirect, the new forum has an XML feed at https://ss64.org/app.php/feed