-contains "True") { Write-Host "删除成功" }else{ Write-Host "删除失败"...:JC ||" Write-Host "|| Version:2.0.1 ||" Write-Host "=====================...========" Write-Host "=== 选项 ===" Write-Host "| 1 获取域内所有域用户账户" Write-Host..."| 2 为域内的所有用户账户尝试注册SPN" Write-Host "| 3 获取现有SPN的凭据的Hash" Write-Host "| 4 爆破获得的Hash" Write-Host..."| 5 删除注册的SPN" Write-Host "| 6 使用SPN审计获得的密码通过LDAP方式再次进行审计" Write-Host "| 7 全部运行" Write-Host
$WindowsVersion = Get-ComputerInfo | Select-Object -ExpandProperty WindowsVersion Write-Host "[*]...." } Elseif ($WindowsVersion -eq 1909) { Write-Host "[*] CVE-2020-0976 is applicable...to your Windows Version." } Else { Write-Host "[+] CVE-2020-0976 is not applicable to...$fix = Get-HotFix -Id KB4551762 -ErrorAction SilentlyContinue if ($fix) { Write-Host..."" Write-Host "================ $title ================" Write-Host "1: Press '1' for check
"`n[+] 系统信息:" Write-Host "操作系统: $($os.Caption) | 版本: $($os.Version)" Write-Host "CPU: $($cpu.Name...)" Write-Host "`n[+] 系统用户:" $users | ForEach-Object { Write-Host "用户: $($_.Name) | 域: $($_....; break } 'help' { Write-Host "`n[+] 可用命令:" Write-Host "'sysinfo...' - 显示系统信息" Write-Host "'network' - 扫描开放端口" Write-Host "'priv' - 检查权限提升机会..." Write-Host "'rev' - 启动反向Shell后门" Write-Host "'persistence' - 通过计划任务设置持久化
will install to $WebPath" Write-Host "After installation, you can visit the site with http://localhost...:8080" Write-Host "Installation started....Write-Host "Checking IIS status..."...-Name AspNetCoreModule -ErrorAction Ignore if($aspNetCoreModule) { Write-Host "IIS ASPNetCoreModule...is ready:" Write-Host $aspNetCoreModule.Name $aspNetCoreModule.Image } else { Write-Host "Downloading
exit } } $test ='abc' $vars = Get-Variable #Write-Host ($vars | Format-List | Out-String) try{...if($outlookWasAlreadyRunning){ write-host "ok..."...#write-host "" #$outline = Get-Event #$vars = Get-Variable #write-host...'$(outline)' #Write-Host ($Args | Format-List | Out-String) #Write-Host ($args...Write-Host $mail.Subject Write-Host $mail.Body write-host "" }
| ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }#$OEMNumbersif($OEMNumbers -eq $null){#Write-Host..."get null"}else{foreach ($OEMNumber in $OEMNumbers) { Write-Host $OEMNumber Write-Host "Deleting...$OEMNumber" pnputil.exe -f -d $OEMNumber Write-Host "`n`n"}}$TencentDrivers2 = pnputil.exe -e..."get null"}else{foreach ($OEMNumber in $OEMNumbers) { Write-Host $OEMNumber Write-Host "Deleting...$OEMNumber" pnputil.exe -f -d $OEMNumber Write-Host "`n`n"}}pnputil.exe -e
{ # 可能引发异常的代码 $result = 10 / 0 } catch [System.DivideByZeroException] { Write-Host..."Error: Division by zero" -ForegroundColor Red exit 1 } catch { Write-Host "An unexpected...error occurred: $_" -ForegroundColor Red exit 1 } finally { Write-Host "Cleaning...{ # 可能引发异常的代码 $result = 10 / 0 } catch [System.DivideByZeroException] { Write-Host...error occurred: $_" -ForegroundColor Red exit 1 } finally { Write-Host "Cleaning
"`n 处理统计:" -ForegroundColor Yellow Write-Host " 总文件数: $totalFiles" -ForegroundColor White Write-Host..."`n 处理计划:" -ForegroundColor Yellow Write-Host " 原始文件数: $totalFiles" -ForegroundColor White Write-Host...Blue if ($Preview) { Write-Host "`n 预览处理效果:" -ForegroundColor Magenta Write-Host...-ForegroundColor Green Write-Host " 最终统计:" -ForegroundColor Yellow Write-Host " 原始文件数: $($originalFiles.Count...Write-Host " 备份位置: $backupFolder" -ForegroundColor Cyan Write-Host "`n 最终文件列表:" -ForegroundColor
string]$url){ $spWeb=Get-SPWeb $url $spDocument=$spWeb.Lists.TryGetList("Documents"); Write-Host..."需要签入文件的文档库:$($spDocument.Title)" $files=$spDocument.CheckedOutFiles Write-Host "需要签入的文件个数...spDocument.GetItemById( $_.ListItemId); $docItem.File.CheckIn("Administrator Check In"); Write-Host
auto_iis_deploy.ps1 #iis自动部署脚本 param( [string]$siteName = "default", [string]$port = "80" ) Write-Host..."siteName:$siteName,port:$port" $physicalPath="d:\www\$siteName" Import-Module WebAdministration Write-Host...(Test-Path $physicalPath)) { mkdir $physicalPath } #创建站点 Write-Host "create or update site.." if..."start website" Start-Website -Name $siteName #启动应用程序池 Write-Host "start webAppPool" Start-WebAppPool...-Name $siteName Write-Host "$siteName successfully started" 这里设置的是一个空站点,可以自己设置文件路径;这里的路径是 $physicalPath
$fix = Get-HotFix -Id KB4551762 -ErrorAction SilentlyContinue if($fix) { Write-Host...You're not vulnerable ***" return } Else { Write-Host "[-] Windows Update $($kb)...for CVE-2020-0796" Write-Host "3: Press '3' Enable SMBv3 Compression" Write-Host "Q: Press '...Write-Host "SMBv3 Compression is set to enabled." } Elseif ($check.DisableCompression -eq 1)...{ Write-Host "SMBv3 Compression is disabled." } } # End function CheckRegSmbv3Compression
为节省以后的时间,写个小的PowerShell脚本,如下: Write-Host "Get Access ..." $Access_Url = "ms-windows-store://pdp/?...Start-Process "https://www.gimp.org/downloads/" Write-Host "Get GraphPad Prism ..."...ProductId=cfq7ttc0k7c3" Start-Process $Publisher_Url Start-Sleep -Seconds 15 Write-Host "Get R ..."...Start-Process "https://www.texstudio.org/" Write-Host "Get Ubuntu ..."...sku=Community" Start-Process $Visual_Studio_Url Write-Host "Get Word ..."
-File if ($files.Count -eq 0) { Write-Host "⚠️ 当前目录下没有文件。"...请先运行:git remote add origin " -ForegroundColor Red exit 1 } Write-Host " 准备逐个提交 $($files.Count...-ForegroundColor Cyan foreach ($file in $files) { $filename = $file.Name Write-Host "`n--- 处理文件...+ 重试最多3次 $retry = 3 $success = $false while ($retry -gt 0 -and -not $success) { Write-Host...-ForegroundColor Red } } Write-Host "`n 所有文件处理完成!" -ForegroundColor Magenta 3.
Domain Name不能为空 return } if(IsNullOrEmpty($AdContainer)){ Write-Host...} else { [bool] $DataValid=$true if(IsNullOrEmpty($AdUser)){ Write-Host...Name不能为空 $DataValid=$false } if(IsNullOrEmpty($AdUserPwd)){ Write-Host...ForEach-Object{ if(IsUserExist -ctx $CurrentContext -userName $_.LogIn) { Write-Host...用户 $_.LogIn 创建成功 } } Write-Host 命令执行结束 } else { Write-Host 无效的文件路径 Write-Host
# 不推荐 foreach ($item in (Get-ChildItem C:\path\to\directory)) { Write-Host $item.Name }# 推荐 Get-ChildItem...C:\path\to\directory | ForEach-Object { Write-Host $_.Name }使用 Select-Object 过滤对象 Select-Object 可以高效地过滤和选择对象属性...Get-ChildItem C:\path\to\directory foreach ($file in $files) { if ($file.Length -gt 1MB) { Write-Host...# 动态生成并执行代码 $code = 'Write-Host "Hello, World!"'...; } } '@ Write-Host ([MyClass]::HelloWorld())通用建议减少 I/O 操作 尽量减少文件读写和网络请求等 I/O 操作,这些操作通常比较耗时。
1、字符串拼接 PS C:\Users\Administrator> $context = "amsi" + "context" PS C:\Users\Administrator> Write-Host...$context 2、ASCII码转换 PS C:\Users\Administrator> Write-Host([char]97+[char]109+[char]115+[char]105+[char...[char]120+[char]116) 3、变量拼接 PS C:\Users\Administrator> $var = "context" PS C:\Users\Administrator> Write-Host..."amsi+$var"amsi+context PSC:\Users\Administrator> Write-Host "amsi$var" 4、字符串格式化 PS C:\Users\Administrator...> $string = "amsi{0}{1}" -f "con","text" PS C:\Users\Administrator> Write-Host $string 5、字符串替换 PS C:
命令拼写错误:如 Write-Host 写成 Write-Host。路径错误:文件路径或命令路径错误。...if ($var -eq "value") { Write-Host "Match" } else { Write-Host "No match" }检查变量引用 确保变量引用正确。...$var = "Hello" Write-Host "$var World"检查命令拼写 确保所有命令拼写正确。Write-Host "Hello, World!"
PowerShell 脚本常见调试方法使用 Write-Host 打印变量值 在关键位置使用 Write-Host 打印变量值,帮助理解变量的状态。...$var = "Hello" Write-Host "Variable value: $var"使用 Set-PSDebug 开启调试模式 使用 Set-PSDebug 开启调试模式,显示每一步执行的命令...Set-PSDebug -Trace 1 $var = "Hello" if ($var -eq "Hello") { Write-Host "Match" } else { Write-Host...[string]$var ) Write-Debug "Variable value: $var" if ($var -eq "Hello") { Write-Host..."Match" } else { Write-Host "No match" } }Test-Function -var "Hello" -Debug使用 ISE 或
RegPath = "Registry::HKEY_USERS\"+$User.SID+"\Software\Microsoft\Terminal Server Client\Servers\" Write-Host..."User:"$User.Name Write-Host "SID:"$User.SID Write-Host "Status:"$User.Status Try {...$QueryPath = dir $RegPath -Name -ErrorAction Stop } Catch { Write-Host "No RDP Connections...History" Write-Host "----------------------------------" continue } foreach($Name in $QueryPath..."User:"$User Write-Host "Server:"$Name } Catch { Write-Host
'\.tif$' } | ForEach-Object { $_.Substring(3).Trim() } # 判断是否有未提交的文件 if ($files.Count -eq 0) { Write-Host...exit } # 遍历每个文件,进行提交和推送 foreach ($file in $files) { Write-Host "Commit File: $file" # 添加文件到暂存区...git commit -m "Commit File $file" # 推送到远程仓库 git push origin main # 请根据你的远程分支名称进行修改 } Write-Host