foreach($keyin$ageList.Keys) {$message='{0} is {1} years old'-f$key,$ageList[$key]Write-Output$message} 我們會遍歷哈希表中的每個鍵,然後使用它來存取值。 這是使用哈希表做為集合時的常見模式。 GetEnumerator() 這讓我們進入GetEnumerator()以遍歷我們的哈希
ArrayList 已被棄用,以支持泛型 List[]泛型清單泛型類型是 C# 中的特殊類型,定義一般化類別,而使用者指定建立時所使用的數據類型。 因此,如果您想要數位或字串清單,您可以定義想要 int 或string 類型的清單。以下是建立字串清單的方式。PowerShell 複製
Get-WinEvent[[-LogName] <String[]>] [-MaxEvents <Int64>] [-ComputerName <String>] [-Credential <PSCredential>] [-FilterXPath <String>] [-Force] [-Oldest] [<CommonParameters>] PowerShell复制 Get-WinEvent[-ListLog] <String[]> [-ComputerName <String>] [-Credential <PSCredential>] [-...
} Caption Property string Caption {get;set;} CodeSet Property string CodeSet {get;set;} CountryCode Property string CountryCode {get;set;} CreationClassName Property string CreationClassName {get;set;} CSCreationClassName Property string CSCreationClassName {get;set;} CSDVersion Property string ...
Get-FileHash -Path C:\Windows\System32\notepad.exe | Format-List //获取某个文件的Hash值(算法SHA256) Get-WMIObject win32_Processor //获取CPU信息 Get-WmiObject Win32_VideoController //获取显卡信息 【获取Windows产品ID】 2种方式 第一种:CMD命令行运行control system查看产品ID ...
Set-PSReadLineOption[-EditMode <EditMode>] [-ContinuationPrompt <string>] [-HistoryNoDuplicates] [-AddToHistoryHandler <Func[string,Object]>] [-CommandValidationHandler <Action[CommandAst]>] [-HistorySearchCursorMovesToEnd] [-MaximumHistoryCount <int>] [-MaximumKillRingCount <int>] [-ShowToolTip...
Select-String Reference Module: Microsoft.PowerShell.Utility Finds text in strings and files. Syntax PowerShellCopy Select-String[-Culture <String>] [-Pattern] <String[]> [-Path] <String[]> [-SimpleMatch] [-CaseSensitive] [-Quiet] [-List] [-NoEmphasis] [-Include <String[]>] [-Exclude...
ForEach(string methodName, object[] 인수)마지막으로 메서드 ForEach() 를 사용하여 컬렉션의 모든 항목에서 메서드를 실행할 수 있습니다.PowerShell 복사 ("one", "two", "three").ForEach("ToUpper") Output 복사 ...
param( [Parameter(Mandatory, ParameterSetName="Computer")] [string[]]$ComputerName, [Parameter(Mandatory, ParameterSetName="User")] [string[]]$UserName, [Parameter()] [switch]$Summary ) 各引数には 1 つのParameterSetName値のみを指定でき、各 Parameter 属性には...
by adding thePSDefaultValueattribute to the description of your parameter, and specifying theHelpproperty ofPSDefaultValue. To provide a help string that describes the default value (100) of theSizeparameter in theGet-SmallFilesfunction, add thePSDefaultValueattribute as shown in the following example...