有没有办法将函数连接到进度条对象?
$buttonAdd_Click = {
create
$loadingbar.Refresh
}
这是我的按钮对象。变量`$ loadingbar是我的progess-bar对象。
这是我的创建功能:
function create()
{
$wshell = New-Object -ComObject Wscript.Shell
$UserList = Import-Csv -Path $txt_csv.Text -Delimiter ";" | Select-Object -ExpandProperty UPN
<# ------- CREATE USERS ------- #>
foreach ($User in $UserList)
{
$OU = $User.path
$UPN = $User.UPN
$Password = $User.password
$Detailedname = $User.firstname + " " + $User.Lastname
$UserFirstname = $User.Firstname
$FirstLetterFirstname = $UserFirstname.substring(0, 1)
$SAM = $User.UPN
$Company = $User.company
$Description = $User.description
$AccountExpirationDate = $User.accountexpirationdate
$params = @{
'Name' = $Detailedname;
'SamAccountName' = $SAM;
'UserPrincipalName' = $UPN + '@ib.nl';
'DisplayName' = $Detailedname;
'GivenName' = $UserFirstname;
'Surname' = $User.Lastname;
'AccountPassword' = (ConvertTo-SecureString $Password -AsPlainText -Force);
'Enabled' = $True;
'PasswordNeverExpires' = $True;
'Path' = $OU;
'Company' = $Company;
'Description' = $Description;
'AccountExpirationDate' = $AccountExpirationDate
}
New-ADUser @params
}
}`
问题:当我点击按钮时,我希望在加载栏中看到创建功能的进程。我怎么能这样做?
另一个问题:Powershell工作室中progessbar和进度baroverlay有什么不同?
答案 0 :(得分:0)
我刚刚解决了问题。我只使用硬编码值来查看我的加载栏是否正常工作。例如,在方法的开头,我使用TextView
,最后我使用了$loadingbar.value = 50;
。代码有点脏,但主人很满意。