$data = Get-Content-Path$Path-Raw | ConvertFrom-Json | ForEach-Object { $_ } | ForEach-Object { # define a string describing the video. This string will be shown in a grid view window $title = '{0,5} [{2}] "{1}" ({3})'-f ([Object[]]$_) # add the original data to the string so when the user select a video, # the details i.e. download URL is still available $title | Add-Member-MemberType NoteProperty -NameData-Value$_-PassThru }
$data | Sort-Object | Out-GridView-Title'Select Video(s)'-OutputMode Multiple | ForEach-Object { # take the download URL from the attached original data $url = $_.Data[5] $filename = Split-Path-Path$url-Leaf $filepath = Join-Path-Path$env:temp-ChildPath$filename $title = 'Video download {0} ({1})'-f$_.Data[1], $_.Data[0] Start-BitsTransfer-Description$title-Source$url-Destination$filepath # you can use a simple web request as well in case BITS isn't available # Invoke-WebRequest -Uri $url -OutFile $filepath -UseBasicParsing
# open video in associated player Invoke-Item-Path$filepath }
OwnerAccount Priority FileList ---------------------------- NT AUTHORITY\NETWORK SERVICE Normal {} NT AUTHORITY\SYSTEM Foreground {https://downloads.dell.com/catalog/CatalogIndexPC.cab} NT AUTHORITY\SYSTEM Foreground {https://dellupdater.dell.com/non_du/ClientService/Catalog/CatalogI...
Get-NetTCPConnection 返回所有当前的 TCP 网络连接,但是此 cmdlet 不会确切告诉您谁在连接到您的计算机。您仅得到 IP 地址:
1 2 3 4 5 6 7
PS> Get-NetTCPConnection-RemotePort443
LocalAddress LocalPort RemoteAddress RemotePort State AppliedSetting OwningProcess ------------------------------------------------------------------------ 192.168.2.1106096013.107.6.171443 Established Internet 21824 192.168.2.1106095920.44.232.74443 Established Internet 4540 192.168.2.1106095652.184.216.226443 Established Internet 13204
使用计算属性,您可以重新计算返回的值,例如,将 IP 地址发送到公开真实来源的 Web 服务。使用相同的技术,您还可以转换在 OwningProcess 中找到的进程 ID,并返回维护连接的进程名称:
# specify the folder that you want to discover # $home is the root folder of your user profile # you can use any folder: $path = 'c:\somefolder' $path = $HOME
# specify the depth you want to examine (the number of levels you'd like # to dive into the folder tree) $Depth = 3