發表文章

目前顯示的是 2月, 2022的文章

如何得知AD欄位長度 以及調整長度限制

圖片
修改AD SCHEMA的方法 1.去AD主機 開啟ADSI EDIT 2.連接SCHEMA 3.找到CN=Department 4. rangeUpper  值即為目前AD該屬性的最大長度 5. 修改 rangeUpper  值 64改成要的長度 footer See also :

Powershell 批次修改AD屬性 修改電腦登入清單(APPEND)

圖片
執行效果 執行前 執行後 下面是Powershell 黃底的部分是你想要加入的電腦清單 $users = Get-ADUser -Filter * -SearchBase 'OU=TESTUSERS,DC=pouchen,DC=com' -properties * #This gets all the users in AD Foreach($user in $users){ $usertemp = get-aduser -Identity $user.DistinguishedName -Properties LogonWorkstations $check=$user.LogonWorkstations if ( $check.length -gt 0) { $info=$user.LogonWorkstations + ", DDCP01,DDCP02,ADDCP01,ADDCP02 “ Set-ADUser -Identity $user.DistinguishedName -LogonWorkstations $info $output=$user.SamAccountName + " logon has been set.“ Write-Output $output }else{ $info=" DDCP01,DDCP02,ADDCP01,ADDCP02 “ Set-ADUser -Identity $user.DistinguishedName -LogonWorkstations $info $output=$user.SamAccountName + " logon has been set.“ Write-Output $output } } footer See also :

用CONSOLE新建Fortigate ADMIN帳號

1.將CONSOLE線接上電腦 2.安裝PUTTY 3.重啟防火牆 4.使用Putty連線防火牆 執行以下指令 Use the following commands to add an admin user account. config system admin edit "admin1" set accprofile "super_admin" set vdom "root" set password 1234 end footer See also :

PowerShell 根據CSV內去清除AD中的屬性

圖片
用 SamAccountName去清除AD特定欄位內容 (範例是以STATE欄位) CSV 內容   指令如下 Import-Module ActiveDirectory   $UsersCsv = Import-CSV c:\removeE5.csv     foreach ( $csvusr in $UsersCsv ) {   Set-ADUser -Identity $csvusr . SamAccountName  -State ' '      $info = $csvusr . SamAccountName + " State-Or-Province content has been remove"        Write-Output   $info }   效果如下   清除後   your code here footer See also :

批量修改OU裡面的屬性

圖片
抓取特定OU裡面的所有帳號 然後修改STATE欄位 有甚麼AD屬性欄位可以改 請參考這裡  https://docs.microsoft.com/en-us/powershell/module/activedirectory/set-aduser?view=windowsserver2022-ps $users = Get-ADUser -Filter * -SearchBase 'OU=FENDER,DC=test,DC=com' -properties * #This gets all the users in AD Foreach($user in $users){ Set-ADUser -Identity $user.DistinguishedName -State 'e5' $info=$user.SamAccountName + "State-Or-Province has been set e5" Write-Output $info } footer See also :