Powershell file

Hi,

I am get this error, when i am trying to run command from .ps1 file. Please let me know, how to run command directly from powershell prompt,Without double clicking on this file.

Regards,

September 1st, 2015 6:49am

Ensure you have AD (ActiveDirectory) Module Available in your machine

You need to install it before you run this script!

http://blogs.msdn.com/b/rkramesh/archive/2012/01/17/how-to-add-active-directory-module-in-powershell-in-windows-7.aspx


Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 6:56am

Hi Chen V,

Thank you for your quick reply. Now i am getting below error. Please see below print-screen.

September 1st, 2015 7:25am

It will be good if you share your code - Remove your domain server names and share with us - We can check and update you

CSV format as well! (Assuming a white space in your input csv file)

Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 7:27am

You do not need to reassign and quote everything:

New-AdUser -Name $user.DisplayName -GivenName $user.Firstname -Surname $user.LastName

Do not use quotes.  You cannot have any blank f

September 1st, 2015 9:23am

Hi Param,

try also this way if you have empty fields:

Import-Module ActiveDirectory
$users = Import-Csv -Path C:\temp\export\workspace.csv
foreach ($user in $users) {
    $properties = @{}
    $user | Get-Member -Type NoteProperty | Select -Expand Name | Foreach {
        if ($user."$_") { $properties.Add("$_", $user."$_") }
    }
    Set-ADUser -Identity $user.sAMAccountName @properties -Verbose
}
Free Windows Admin Tool Kit Click here and download it now
September 1st, 2015 9:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics