試圖建立一個功能類似如下:PowerShell的功能限制數據類型
Function Get-SqlErrorLogPrevious24 {
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True,Position=1)]
[Microsoft.SqlServer.Management.Smo.Server]$Server
)
($Server.ReadErrorLog()).where{$_.logdate -ge ((Get-Date).AddHours(-24))}
}
什麼我雖然注意到了,就是我可以在短短的字符串傳遞,而不是服務器對象。
有沒有辦法在Powershell中強制執行傳入的數據類型,還是總是隱式地將字符串轉換爲SMO對象?