- <
- .SYNOPSIS
- Finds duplicates in the GD archive – A script
- for New Year’s eve!
- .DESCRIPTION
-
- .NOTES
- File Name : Count-GDDuplicate.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2
- .LINK
- http://pshscripts.blogspot.com/2010/12/count-gdduplicateps1.html
- .EXAMPLE
- Psh[Cookham8]>C:\foo\Count-GdDuplicate.ps1
- Count-GDDuplicate.ps1 - v 1.0.1
-
- 99 shows have duplicates
- 109 shows are duplicates of others
-
-
-
-
-
-
-
-
-
-
- $GDDiskRoot = "M:"
- $DeadShowBase = $GDDiskRoot + "\gd"
-
-
- "DuplicateCount.ps1 - v 0.0.1"
- "+---------------------------------+"
- "! Find Duplicate Shows : $DeadShowBase !"
- "+---------------------------------+"
- ""
-
- $starttime = Get-Date
- set-strictmode -off
-
-
-
- $Dir = ls $DeadShowBase | where {$_.psiscontainer}
- $DeadShows = $Dir.count
- if ($DeadSHows -le 0) {"no shows found - check constants"; return}
-
-
-
- $shows =@{}
-
- $j = 0
- foreach ($show in $dir){
- $j++
- $showdate = $show.name.substring(0,10)
- if ($shows.$showdate) {
- $shows.$showdate++
- }
- else {
- $shows += @{$showdate=1}
- }
-
- }
-
- $shows = $shows.getenumerator() | Sort name
- $totaldups = 0
- $totaldupshows = 0
- foreach ($show in $shows){
- if ($show.value -gt 1) {
-
- $totaldups++
- $totaldupshows += $show.value - 1
- }
- }
-
-
- "{0} shows have duplicates" -f $totaldups
- "{0} shows are duplicates of others" -f $totaldupshows
Technorati Tags:
Grateful Dead
- <
- .SYNOPSIS
- This script displays all the WMI namespaces within a Windows system
- .DESCRIPTION
- This script uses Get-WMIObject to retrieve the names of all the namespaces
- within a system.
- .NOTES
- File Name : Get-WMINameSpace.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/10/get-wminamespaceps1.html
- .EXAMPLE
- PSH [C:\foo]: .\Get-WMINameSpace.ps1
- 37 Namespaces on: Cookham8
-
- Namespace
- ---------
- ROOT
- ROOT\aspnet
- ROOT\CIMV2
- ROOT\CIMV2\Security
- ROOT\CIMV2\Security\MicrosoftTpm
- ... {Remainder of list snipped to save space on this page}
-
-
- # Set computer name
- $comp = "."
-
- $Namespace = get-wmiobject __namespace -namespace 'root' -list -recurse -computer $comp
- $hostname = hostname
-
-
- "{0} Namespaces on: {1}" -f $namespace.count, $hostname
- $NameSpace| sort __namespace | Format-Table @{Expression = "__Namespace"; Label = "Namespace"}
- <
- .SYNOPSIS
- This script checks whether a parameter is a Loopback Address
- .DESCRIPTION
- This script checks to see if the passsed string is an IPV4
- or an IPv6 loopback address and if so, displays details.
- .NOTES
- File Name : Get-LoopBack.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/system.net.ipaddress.isloopback.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-LoopBack.ps1
- Your input address: \127.0.0.1\ is an IPv4 loopback address whose internal format is: 127.0.0.1.
- .EXAMPLE
- PSH [C:\foo]: .\Get-LoopBack.ps1 ::1
- Your input address: \::1\ is an IPv6 loopback address whose internal format is: ::1.
- .EXAMPLE
- PSH [C:\foo]: .\Get-LoopBack.ps1 131.107.2.200
- Your input address: \131.107.2.200\ is not a loopback address.
- .PARAM
- $IPAddress - Address to look up to see if it's Loopback
-
- param (
- [String] $IpAddress = "127.0.0.1"
- )
-
- $loopBack=" is not a loopback address.";
-
-
- $Address = [System.Net.IPAddress]::Parse($IpAddress);
-
-
-
- if([System.Net.IPAddress]::IsLoopback($Address) -and ($address.AddressFamily -eq [System.Net.Sockets.AddressFamily]::InterNetworkV6) ) {
- $loopBack = " is an IPv6 loopback address " +
- "whose internal format is: " + $Address.ToString() + ".";
- }
- <
- .SYNOPSIS
- This script gets and displays basic DNS Information about a host.
- .DESCRIPTION
- This script just gets and displays host details returnd by GetHostByName.
- .NOTES
- File Name : Get-ByName.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/system.net.dns.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-HostByName.ps1
-
- HostName : contoso.com
- Aliases : {www.contoso.com}
- AddressList : {207.46.197.32, 207.46.232.182}
-
- $hostInfo = [system.net.Dns]::GetHostByName("www.contoso.com");
- $hostinfo | fl * -force
- <
- .SYNOPSIS
- This script deletes a file from an FTP Server
- .DESCRIPTION
- This script is a rewrite of an MSDN Sample
- .NOTES
- File Name : Remove-FtpFile.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Remove-FtpFile.ps1
- Delete status: 250 DELE command successful.
-
- $ServerUri = New-Object System.Uri "ftp://www.reskit.net/powershell/foo.txt"
-
-
-
-
- if ($ServerUri.Scheme -ne [system.Uri]::UriSchemeFtp) {
- " Bad URI"; return
- }
-
-
- $request = [system.Net.FtpWebRequest]::Create($serverUri)
- $request.Method = [System.Net.WebRequestMethods+ftp]::Deletefile
- $Request.Credentials = New-Object System.Net.NetworkCredential "anonymous","tfl@psp.co.uk"
-
- $response = $request.GetResponse()
- "Delete status: {0}" -f $response.StatusDescription
- $response.Close();
- <
- .SYNOPSIS
- This script Uploads a text file to an FTP Server using PowerShell.
- .DESCRIPTION
- This script first creates an FTP 'web' request to upload a file. Then the
- source file is read from disk and written up to the FTP Server. A response
- is then displayed. This is a rewrite of an MSDN Sample.
- .NOTES
- File Name : Copy-FileToFtp.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/10/copy-filetoftpps1.html
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/ms229715.aspx
- .EXAMPLE
- PSH [C:\foo]: .Copy-FileToFtp.ps1
- Upload File Complete, status 226
- 226 Transfer complete.
-
-
-
- $Request = [System.Net.FtpWebRequest]::Create("ftp://www.reskit.net/powershell/Greetings.Txt")
- $Request.Method = $Request.Method = [System.Net.WebRequestMethods+ftp]::UploadFile
-
-
- $Request.Credentials = New-Object System.Net.NetworkCredential "anonymous","tfl@psp.co.uk"
-
-
- $FileContents = [System.IO.File]::ReadAllBytes("C:\foo\scriptlib.zip")
- $Request.ContentLength = $fileContents.Length
- $RequestStream = $request.GetRequestStream()
- $RequestStream.Write($FileContents, 0, $FileContents.Length)
- $RequestStream.Close()
- $Response = $Request.GetResponse()
- "Upload File Complete, status {0}" -f $Response.StatusDescription
- $Response.Close()
- <
- .SYNOPSIS
- This script encodes and decodes an HTML String
- .DESCRIPTION
- This script used
- .NOTES
- File Name : Show-HtmlCoding.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://www.pshscripts.blogspot.com
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/ee388364.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Show-HtmlCoding.ps1
- Original String: <this is a string123> & so is this one??
- Encoded String : <this is a string123> & so is this one??
- Decoded String : <this is a string123> & so is this one??
- Original string = Decoded string?: True
-
-
-
- $Str = "<this is a string123> & so is this one??"
-
-
- $Encstr = [System.Net.WebUtility]::HtmlEncode($str)
-
-
- $Decstr = [System.Net.WebUtility]::HtmlDecode($EncStr)
-
-
- "Original String: {0}" -f $Str
- "Encoded String : {0}" -f $Encstr
- "Decoded String : {0}" -f $Decstr
- $eq = ($str -eq $Decstr)
- "Original string = Decoded string?: {0}" -f $eq
- <
- .SYNOPSIS
- This script used FTP to get and display the root of an FTP site.
- .DESCRIPTION
- This script re-implements an MSDN sample.
- .NOTESW
- File Name : Get-FtpDirectory.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- htthttp://pshscripts.blogspot.com/2010/09/get-ftpdirectoryps1.html
- MSDN sample posted tot:
- http://msdn.microsoft.com/en-us/library/ms229716.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-FtpDirectory.ps1
- drwxrwxrwx 1 user group 0 Dec 4 2005 pcpro
- drwxrwxrwx 1 user group 0 Sep 23 15:18 PowerShell
- ... {Listing truncated}
- Download Complete, status:
- 226-Maximum disk quota limited to 100000 Kbytes
- Used disk quota 78232 Kbytes, available 21767 Kbytes
- 226 Transfer complete.
-
-
- $Request = [System.Net.WebRequest]::Create("ftp://www.reskit.net")
- $Request.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectoryDetails
-
-
-
- $Request.Credentials = New-Object System.Net.NetworkCredential "Anonymous",tfl@psp.co.uk
-
- $Response = $Request.GetResponse()
- $ResponseStream = $Response.GetResponseStream()
-
-
- $Reader = new-object System.Io.StreamReader $Responsestream
- [System.Console]::Writeline($Reader.ReadToEnd())
-
-
- "Download Complete, status:"
- $response.StatusDescription
-
-
- $Reader.Close()
- $Response.Close()
-
- .SYNOPSIS
- This script used FTP to get and display a text file.
- .DESCRIPTION
- This script re-implements an MSDN Sample
- .NOTESW
- File Name : Get-FtpFile.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell Version 2.0
- .LINK
- This script posted to:
- http://pshscripts.blogspot.com/2010/09/get-ftpfileps1.html
- MSDN sample posted to:
- http://msdn.microsoft.com/en-us/library/ms229711.aspx
- .EXAMPLE
- PSH [C:\foo]: .\Get-FtpFile.ps1'
- This is Hello.Txt from www.reskit.net
- Have a great day!
-
- Download Complete, status:
- 226-Maximum disk quota limited to 100000 Kbytes
- Used disk quota 78232 Kbytes, available 21767 Kbytes
- 226 Transfer complete.
-
-
-
- $Request = [System.Net.WebRequest]::Create("ftp://www.reskit.net/hello.txt");
- $Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
-
-
-
- $Request.Credentials = New-Object System.Net.NetworkCredential "Anonymous","tfl@psp.co.uk"
- $ResponseStream = $Response.GetResponseStream()
-
-
- $Reader = new-object System.Io.StreamReader $ResponseStream
- [System.Console]::Writeline($Reader.ReadToEnd())
-
-
- "Download Complete, status:"
- $response.StatusDescription
-
-
- $Reader.Close()
- $Response.Close()