[array],[bool],[byte],[char],[datetime],[decimal],[double],[guid],[hashtable],[int16],[int32],[int],[int64],[long],[nullable],[psobject],[regex],[sbyte].[scriptblock],[single],[float],[string],[switch],[timespan],[type],[uint16],[uint32],[uint64],[ XML ] 变量的幕后...
[DateTime]::UtcNow $record = "AzureActiveDirectory" $resultSize = 5000 $intervalMinutes = 60 #Start script [DateTime]$currentStart = $start [DateTime]$currentEnd = $end Function Write-LogFile ([String]$Message) { $final = [DateTime]::Now.ToUniversalTime().ToString("s") + ":" + $...
helpGet-Help-ParameterName 說明信息顯示Name參數是位置參數,且在使用時,必須在第一個位置(位置零)指定。 Output -Name <System.String> Gets help about the specified command or concept. Enter the name of a cmdlet, function, provider, script, or workflow, such as `Get-Member`, a conceptual article...
param( [Parameter(Mandatory)] [ValidateScript({$_ -ge (Get-Date)})] [DateTime]$EventDate ) 次の例では、変数 $date の値は現在の日時以下である必要があります。PowerShell コピー [ValidateScript({$_ -le (Get-Date)})] [DateTime]$date = (Get-Date) 注...
Get-Date [[-Date] <DateTime>] [-Year <Int32>] [-Month <Int32>] [-Day <Int32>] [-Hour <Int32>] [-Minute <Int32>] [-Second <Int32>] [-Millisecond <Int32>] [-DisplayHint <DisplayHintType>] [-Format <String>] [-AsUTC] [<CommonParameters>]Power...
ScriptBlock 包含表示当前管道对象的 $_ 变量。 时间戳字符串由用句点替换的冒号分隔。 New-Item 使用Path 参数来指定新目录的位置。 路径包含 $timestamp 变量作为目录名称。 Type 参数指定创建目录。示例9:转换 Unix 时间戳本示例将 Unix 时间(由自 1970-01-01 01 0:00:00 以来的秒数)转换为 DateTime。
ToString()使用当前区域性设置将DateTime对象转换为字符串。 但是,PowerShell 表达式解释始终使用固定区域性设置。 例如,在具有en-US区域性的系统上,ToString()方法使用en-US区域性设置格式化日期。 PowerShell # Get date using current culture en-US(Get-Date2024-03-19).ToString()3/19/202412:00:00AM# Get...
For example, suppose you run this simple two-line script: Copy $a = new-object system.globalization.datetimeformatinfo $a You’re going to get back information similar to this: Copy AMDesignator : AM Calendar : System.Globalization.GregorianCalendar DateSeparator : / FirstDayOfWeek : Sunday ...
The script block runs for each set of three digits that needs to be replaced. PowerShell Copy "072101108108111" -replace "\d{3}", {return [char][int]$_.Value} Output Copy Hello Containment operators The containment operators (-contains, -notcontains, -in, and -notin) are si...
gi 获取指定的文件或者目录 Get-Item gp 获取文件或目录的属性 Get-ItemProperty ii 使用对应的默认windows程序运行文件或者目录 Invoke-Item — 连接两个路径为一个路径 Join-Path mi, mv, move 移动文件或者目录 Move-Item ni 创建新文件或者目录 New-Item ri, rm, rmdir,del, erase, rd 删除空目录或者文件...