+ $DBDataFile = Get-Counter <<< -Counter '\MSSQL$SQL2K8_01:Databases(*)\Data File(s) Size (KB)' -MaxSamples 1 + CategoryInfo : InvalidResult: (:) [Get-Counter], Exception + FullyQualifiedErrorId : CounterApiError,Microsoft.PowerShell.Commands.GetCounterCommandData...
(Measure-Command{ &$test.Value-Count$_}).TotalMilliseconds [pscustomobject]@{ CollectionSize =$_Test =$test.Key TotalMilliseconds = [math]::Round($ms,2) } [GC]::Collect() [GC]::WaitForPendingFinalizers() }$groupResult=$groupResult|Sort-ObjectTotalMilliseconds$groupResult|Select-Object*...
(Measure-Command{ &$test.Value-Count$_}).TotalMilliseconds [pscustomobject]@{ CollectionSize =$_Test =$test.Key TotalMilliseconds = [math]::Round($ms,2) } [GC]::Collect() [GC]::WaitForPendingFinalizers() }$groupResult=$groupResult|Sort-ObjectTotalMilliseconds$groupResult|Select-Object*, @...
In this example, the directory size is about 37 GB (this PowerShell command ignores NTFS file system compression if it is enabled). To round the results to two decimal places, use the command: "{0:N2} GB" -f ((Get-ChildItem D:\ISO -force -Recurse -ErrorAction SilentlyContinue| measure...
Get-Help Get-History Get-Job Get-Module Get-PSHostProcessInfo Get-PSSession Get-PSSessionCapability Get-PSSessionConfiguration Get-PSSubsystem Import-Module Invoke-Command Invoke-History New-Module New-ModuleManifest New-PSRoleCapabilityFile New-PSSession ...
Add helper in EnumSingleTypeConverter to get enum names as array (#17785) (Thanks @fflaten!) Return correct FileName property for Get-Item when listing alternate data streams (#18019) (Thanks @kilasuit!) Add -ExcludeModule parameter to Get-Command (#18955) (Thanks @MartinGC94!) Update Nam...
使用过滤器替代函数会清除嵌套的复杂度而使代码更为简洁且易读,可以使用Get-Command查看Get-RecentlyStarted的详细信息。PowerShell规定过滤器是函数的特例,因为使用Function和Filter类型查找命令都会返回前面的过滤器,如:展开表 PS C:\> Get-Command Get-RecentlyStarted -type FunctionCommandType Name Definition-...
function Get-SmallFiles { Param($Size) Get-ChildItem $HOME | Where-Object { $_.Length -lt $Size -and !$_.PSIsContainer } } In the function, you can use the $Size variable, which is the name defined for the parameter. To use this function, type the following command: PowerShell Co...
To install this module with WMF 5 and up (to get the latest GetSTFolderSize module version available), simply run this command (requires an internet connection): Install-Module -Name GetSTFolderSize Be aware that the function has the name "Get-STFolderSize" when you use the module version...
Drop this script into a directory in your path, and you can quickly find the sizes for directories in your file system. Remember that it outputs objects, so you can add tasks such as sort and filter, for example: Get-DirStats -Path C:\Temp | Sort-Object -Property Size This command ou...