About Me

My photo
HANUMANGARH, RAJASTHAN, India

Tuesday, 20 December 2022

Update User properties in Active Directory from CSV

 

  1. Import-Module ActiveDirectory
  2. $USERS = Import-CSV c:\users.csv
  3. $USERS | foreach {
  4. $empid=$_.employeeid
  5. $company=$_.company
  6. $title=$_.title
  7. $department=$_.department
  8. $Division=$_.division
  9. $pobox=$_.pobox
  10. $city=$_.city
  11. Set-ADUSer -Identity $_.samaccountname -Replace @{employeeID=$empid; company=$company; title=$title; department=$department; division=$division; postofficebox=$pobox; l=$City}
  12. }


=====================================================================================================

Import-Module ActiveDirectory

$USERS = Import-CSV c:\users.csv

$empid=$USERS.employeeid
$company=$USERS.company
$title=$USERS.title
$department=$USERS.department
$Division=$USERS.division
$pobox=$USERS.pobox
$city=$USERS.city
$acc=$USERS.samaccountname

ForEach ($user in $USERS) {
Get-ADUser -Filter "samaccountname -eq '$Acc'" | Foreach {
Set-ADUser $ -Replace @{title = $title}
Set-ADUser $
 -Replace @{company = $company}
Set-ADUser $ -Replace @{department = $department}
Set-ADUser $
 -Add @{division = $division}
Set-ADUser $ -Replace @{postOfficeBox = $pobox}
Set-ADUser $
 -Replace @{l = $city}
Set-ADUser $_ -Replace @{employeeid = $empid}
}
}

Monday, 19 December 2022

Create an ICON in system Tray

 #Create an ICON in system tray

Param

 (

[String]$Restart

 )

Hostname to IP address

 $location = Read-Host "CSV Path: "

$Names = Import-Csv -Path $location


foreach($n in $Names)

{

    try {

        $Computer = [system.net.dns]::resolve($n.NAME) | Select HostName,AddressList 

        $IP = ($Computer.AddressList).IPAddressToString

        New-Object PSObject -Property @{IPAddress=$IP; Name=$Computer.HostName} | Export-Csv \\filepath\Working.csv -NoTypeInformation -Append

    } catch {

        Write-Host "$($n.NAME) is unreachable."

        Write-Output $n | Export-Csv \\Filepath\Unreachable.csv -Append -Encoding ASCII

    }

}

Export contact from Justdial

  Extract Data From JustDial using Selenium Let us see how to extract data from Justdial using Selenium and Python. Justdial is a company th...