【发布时间】:2022-10-24 16:52:24
【问题描述】:
我在Function script:Set-Variables{} 中遇到过这个“script”关键字
知道为什么要使用它吗?
Function script:Set-Variables {
$PerTraceArr = @()
$script:ASNOwnerArr = @()
$ASNOwnerObj = New-Object PSObject
$ASNOwnerObj | Add-Member NoteProperty "ASN"("AS0")
$ASNOwnerObj | Add-Member NoteProperty "ASN Owner"("EvilCorp")
$ASNOwnerArr += $ASNOwnerObj #Add some values so the array isn't empty when first checked.
$script:i = 0
$script:x = 0
$script:z = 0
$script:WHOIS = ".origin.asn.cymru.com"
$script:ASNWHOIS = ".asn.cymru.com"
} #End Set-Variables
【问题讨论】:
-
是scope modifier 决定变量、函数等的可见性吗?
标签: powershell function