Set userpath to homefolder using powershell

I've created a partition " H:\ "  with several folders for different usergroups.
One of these groups is ICT.
When i run the following script the path for the users is set to the correct folder
Get-ADUser -filter * -SearchBase "OU=All_ICT,DC=LUMO,DC=local" | 
% { Set-ADUser $_ -HomeDrive "H:" -HomeDirectory ("\\ServerLUMO\ICT_share\" + $_.SamAccountName) }
The problem is that this path isn't applied. When i go to the usersprofile in AD and i backspace one caracter and retype it i can click " Apply" and it works like a charm....
My question is, how can i achieve this in the powershellscript?

sorry, same problem. It doesn't automatically make the folders for the users
Ah sorry, I didn't realize that you didn't have the paths already created. Try this:
Get-ADUser -Filter * -SearchBase 'OU=All_ICT,DC=LUMO,DC=local' | ForEach {
$homeDir = Join-Path -Path '\\ServerLUMO\ICT_share' -ChildPath $_.SamAccountName
If (!(Test-Path -Path $homeDir)) { New-Item -Path $homeDir -ItemType Directory }
Set-ADUser $_.SamAccountName -HomeDrive 'H:' -HomeDirectory $homeDir
Don't retire TechNet! -
(Don't give up yet - 12,700+ strong and growing)

Similar Messages

  • Set Primary DNS Suffix Using Powershell

    For a Windows Server 2012 installation, what Powershell cmdlet can be used to change the Primary DNS Suffix ? I've tried using 'Set-DnsClientGlobalSetting -SuffixSearchList contoso.com' but this only alters the DNS Suffix Search List, not the primary DNS
    suffix.

    You might want to take you question to one of two forums that specialist in scripting issues.
    For PowerShell specific questions -
    http://social.technet.microsoft.com/Forums/en-US/home?forum=winserverpowershell
    For general scripting questions -
    http://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG
    They have a lot of really sharp scripting people in those forums.
    .:|:.:|:. tim

  • How to Install DNS ROLE and its FQDN service and Reverse Lookup zone in Server Core using Powershell?

    Hi
    I am Setting A Lab Scenario That the PC name "Core2012" i.e. Server Core 2012 Will be Domain Controller.
    Using PowerShell I have done this Task
    Change hostname ; Configure IP address and Preferred DNS address ; Disable IPv6 ;
    Configure Firewall ; Even Active Directory Role install.
    Now problem occur
    Well I have know to install DNS role install-WindowsFeature DNS
    Ok
    But; 
    How to configure FQDN ; Restore mode password ; Setting up global catalog server ;and configure Reverse Lookup zone Using powershell
    I have search many Forums but I am not getting to touch with it.
    So I Need a help to set and Configure DNS using Powershell
    Thank You!!!
    sagarpdalvi

    Hi Sagarpdalvi,
    To set the Safe mode password with powershell, please refer to the cmdlet Install-ADDSDomainController, to enable global catalog(GC), please run the cmdlet "Set-ADObject" after install Active Directory on the core server, to configure Reverse Lookup zone,
    please refer to the cmdlet
    Add-DnsServerPrimaryZone.
    To configure DC with powershell, please check the scripts:
    Installing a Domain Controller on Windows Server 2012
    R2 Core
    Enabling and Disabling the Global Catalog
    To configure DNS, the Domain Name System (DNS) Server Cmdlets should be helpful for you:
    http://technet.microsoft.com/en-us/library/jj649850.aspx
    I hope this helps.

  • Not able to set security group without mail enabled as site collection admin using powershell in sharepoint online site - office 365

    not able to set security group without mail enabled as site collection admin using powershell in sharepoint online site - office 365?
    Any idea?

    after few days test in my lab, I can see that only email enabled group can be added as site collection admin using POWERSHELL.
    hope this helps who stuck like me!! :-)

  • How to get Document Set property values in a SharePoint library in to a CSV file using Powershell

    Hi,
    How to get Document Set property values in a SharePoint library into a CSV file using Powershell?
    Any help would be greatly appreciated.
    Thank you.
    AA.

    Hi,
    According to your description, my understanding is that you want to you want to get document set property value in a SharePoint library and then export into a CSV file using PowerShell.
    I suggest you can get the document sets properties like the PowerShell Command below:
    [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
    $siteurl="http://sp2013sps/sites/test"
    $listname="Documents"
    $mysite=new-object microsoft.sharepoint.spsite($siteurl)
    $myweb=$mysite.openweb()
    $list=$myweb.lists[$listname]
    foreach($item in $list.items)
    if($item.contenttype.name -eq "Document Set")
    if($item.folder.itemcount -eq 0)
    write-host $item.title
    Then you can use Export-Csv PowerShell Command to export to a CSV file.
    More information:
    Powershell for document sets
    How to export data to CSV in PowerShell?
    Using the Export-Csv Cmdlet
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Set multi user column with PowerShell used to work in 2010 but no longer works in 2013

    In SharePoint 2010 I used PowerShell to set the value of multi user people columns and it worked really well.  I attempt to use the same PowerShell to set the same column type in SharePoint 2013 and it fails.
    here is the PowerShell that I use in 2010:
    $web = Get-SPWeb "http://intranet"
    $list = $web.lists["TestList"]
    $item = $list.items.add()
    $item["Title"] = "Test multi user column"
    $users = @("Domain\user1", "Domain\user2")
    $userList = new-object Microsoft.SharePoint.SPFieldUserValueCollection
    foreach($user in $users)
    $spUser = $web.EnsureUser($user)
    $userValue = new-object Microsoft.SharePoint.SPFieldUserValue($web, $spUser.ID, $spUser.Name)
    $userList.Add($userValue)
    $item["MultiUserColumn"] = $userList
    $item.update()
    I have used this on three SharePoint 2013 farms with differing results.  On two of them I receive an error when running $item.update(): Exception calling "Update" with "0" argument(s): "Invalid look-up value.  A look-up
    field contains invalid data. Please check the value and try again."
    If I take one of the users out of the $users list then it works fine, but it will not allow multiple users to be set with PowerShell.  I can use the GUI to add more than one user but not PowerShell.
    Does anyone know if these methods have changed in 2013? I haven't been able to find anyone else with this issue.
    mmm... coffee...

    Not sure but maybe something to do with casting. Below is the code snippet from one of the blogs. Try modifying your script like below and see if still you get the error
    [Microsoft.SharePoint.SPFieldUserValueCollection]$lotsofpeople = New-Object Microsoft.SharePoint.SPFieldUserValueCollection
    $user1 = $w.EnsureUser("domain\user1");
    $user1Value = New-Object Microsoft.SharePoint.SPFieldUserValue($w, $user1.Id, $user1.LoginName)
    $user2 = $w.EnsureUser("domain\user2");
    $user2Value = New-Object Microsoft.SharePoint.SPFieldUserValue($w, $user2.Id, $user2.LoginName);
    $lotsofpeople.Add($user1Value);
    $lotsofpeople.Add($user2Value);
    $i["lotsofpeoplefield"] = $lotsofpeople;
    $i.Update();
    #-or-
    $l.Fields["lotsofpeoplefield"].ParseAndSetValue($i,$lotsofpeople);
    $i.Update();
    Reference to the link
    http://social.technet.microsoft.com/wiki/contents/articles/20831.sharepoint-a-complete-guide-to-getting-and-setting-fields-using-powershell.aspx
    Geetanjali Arora | My blogs |

  • How to set security group as primary site collection admin and secondary site collection admin using powershell in sharepoint online site - office 365?

    How to set security group as primary site collection admin and secondary site collection admin using powershell in sharepoint online site - office 365?

    Hi,
    According to your description, my understanding is that you want to set security group as admin of primary and secondary site collection using PowerShell command in office 365.
    I suggest you can use the command below to set the group to site owner, then it will have the site collection admin permission.
    Set-SPOSite -Identity https://contoso.sharepoint.com/sites/site1 -Owner [email protected] -NoWait
    Here are some detailed articles for your reference:
    https://technet.microsoft.com/en-us/library/fp161394(v=office.15)
    http://blogs.realdolmen.com/experts/2013/08/16/managing-sharepoint-online-with-powershell/
    Thanks
    Best Regards
    Jerry Guo
    TechNet Community Support

  • Set Default Printer based on user setting using Powershell script

    Hi 
    I would like to create a script that runs on user log off and captures the default printer (set manually by the user) and then another script to reapply the settings (saved upon log off) when the user logs back in.
    This is because local printers are set as default printer (PDF Creator Programs) when we all use Network Printers so this means a user has to set default printer to the network printer all the time.
    I have found this script to start with:
    $Printer = Get-WmiObject -namespace root\cimv2 -Query “select * from Win32_Printer Where Default = TRUE” -Impersonation 3 | select name | out-file C:\temp\Printer.txt
    But the out file looks like this:
    name
    \\PrinterserverName\Accounts01
    Which I dont see how it can be used on another script plus there are spaces after\Account01 
    Any Ideas please?
    M
    Maelito

    Hi Maelito,
    According to your description, you want to export the default printer name to text file, then read this printer name from text file and set the default printer via Powershell:
    #save printer name to text file
    Get-WmiObject -namespace root\cimv2 -Query “select * from Win32_Printer Where Default = TRUE” -Impersonation 3 | select -ExpandProperty name | out-file C:\temp\Printer.txt
    # read printer name from text file and set default printer
    $name=get-content C:\temp\Printer.txt
    (Get-WmiObject -Class Win32_Printer -Filter "Name='$name'").SetDefaultPrinter()
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • How to use Powershell to set delegate for user mailbox in Exchange 2010 and Office 365

    Hello,
    Can you please tell me if I can set delegate for user mailbox in Exchange 2010 or Office 365 using Powershell?
    If I can, then how can I do that? (which Powershell commands for setting the delegate?)
    Many thanks, and have a good day!

    Hi,
    If you wanted to add a delegate to possiblly a large number of users or you do this during mailbox provisioning. So the following script will use
    impersonation to access another users mailbox and add a delegate.
    $mbtoDelegate = "[email protected]"
    $delegatetoAdd = "[email protected]"
    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind
    $service.AutodiscoverUrl($aceuser.mail.ToString())
    $service.ImpersonatedUserId = new-object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress,
    $mbtoDelegate);
    $mbMailbox = new-object Microsoft.Exchange.WebServices.Data.Mailbox($mbtoDelegate)
    $dgUser = new-object Microsoft.Exchange.WebServices.Data.DelegateUser($delegatetoAdd)
    $dgUser.ViewPrivateItems = $false
    $dgUser.ReceiveCopiesOfMeetingMessages = $false
    $dgUser.Permissions.CalendarFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::Editor
    $dgUser.Permissions.InboxFolderPermissionLevel = [Microsoft.Exchange.WebServices.Data.DelegateFolderPermissionLevel]::Reviewer
    $dgArray = new-object Microsoft.Exchange.WebServices.Data.DelegateUser[] 1
    $dgArray[0] = $dgUser
    $service.AddDelegates($mbMailbox, [Microsoft.Exchange.WebServices.Data.MeetingRequestsDeliveryScope]::DelegatesAndMe, $dgArray);
    Hope this helps.

  • How to set volume using Powershell script?

    I would like to know on how to set volume under Window 7 Home 64 bits system using Powershell script.
    Such as 8000 levels as default
    Does anyone have any suggestions?
    Thanks in advance for any suggestions
    Thanks in advance for any suggestions

    Try this.
    Function Set-SpeakerVolume{
    Param (
    [switch]$min,
    [switch]$max,
    [int]$Percent
    $wshShell = new-object -com wscript.shell
    If ($min){
    1..50 | % {$wshShell.SendKeys([char]174)}
    ElseIf ($max){
    1..50 | % {$wshShell.SendKeys([char]175)}
    elseif($Percent){
    1..50 | % {$wshShell.SendKeys([char]174)}
    1..($Percent/2) |% {$wshShell.SendKeys([char]175)}
    Else{
    $wshShell.SendKeys([char]173)
    This works in Windows 8.1.
    Stolen / Modified from
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/07/28/weekend-scripter-cheesy-script-to-set-speaker-volume.aspx, which took me 20 seconds of (apparently) lucky searching.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Set user inherit permissions check box using powershell

    Hi All,
    How can I set the the  "include inherit permissions from this objects parent" propertiy in Active Directory user object to a list of users using powershell.
    This option is not checked for some of my users and I'll like to set it using a powershell script.
    Thanks
    Simon
    MCSA, MCSE, MCITP:SA, MCITP:EA, MCITP:Enterprise Messaging Administrator 2010, CCNA

    download Quest Active Directory:
     Get-QADUser -SizeLimit 0 | ? {$_.DirectoryEntry.ObjectSecurity.AreAccessRulesProtected} | Set-QADObjectSecurity -UnLockInheritance
    or 
    Get-QADUser -SizeLimit 0 | ? {$_.security.PermissionInheritanceLocked} | Set-QADObjectSecurity -UnlockInheritance
    or 
    $user = [ADSI]"LDAP://cn=kazun,ou=test,dc=contoso,dc=com"
    $acl = $ouser.objectSecurity
    $isProtected = $false # allows inheritance
    $preserveInheritance = $true # preserve inherited rules
    $acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
    $user.commitchanges()
    I had this issue and using both of Kazun's methods worked. A mod should mark this as the answer.Paul Frankovich

  • How to set IPaddress to a VM which has Linux OS using powershell remoting.

    I have downloaded the SetLinuxVM scripts for setting the ipaddress of virtual machine which has Linux as OS. I have 2 different Hyperv host machines for Eg: HostServer1 and HostServer2  and I have installed SetLinuxVM scripts on server HostServer1 but
    my LinuxVM is created in HostServer2 and is highly available.
    Now I have development server from where I connect to any of these HyperV servers remotely .
    I have created powershell remote session from my development server to HostServer1 where SetLinuxVM scripts are installed and excuting the script as given below.
    Set-LinuxVM -VMName "TestLinuxVM" -Manager "Hyper-V" -VMHost "HostServer2"
    -Username "root" -Password "Gen#123" -Hostname "TestLinuxSrv " -IPAddress "192.168.2.2" -SubnetMask "255.255.0.0" -GatewayAddress "192.168.2.1" -PrimaryDNSAddress "8.8.8.8" 
    Even though I am providing the -VMHost and even if the VM is in cluster its not executing the scripts and I am getting the error  WMI not available.
    Its working fine if the scripts are installed on HostServer2 where the LinuxVM is created but my question is that do we need to install the scripts on all HyperV hosts then whats the use of the above parameter -VMHost "HostServer2"  because if
    the hyperv host is remotely connected using powershell we need to provide the VMHost name in the above scripts.
    From the examples provided in the SetLinuxVM module my understanding is that if the SetLinuxVM module is installed in any of the Hyperv servers which  are in a cluster and even though the VM is created in any of the servers and is highly available by just
    providing the VMHost for that particular VM we can set the IPadress ,hostname etc by connecting remotely using powershell to the HostServer which has SetLinuxVM module by providing the VMHost name in the above script .
     Hoping that my problem will be resolved at your earliest convenience.
    Thanks in advance,
    Fayaz Syed.
    FayazSyed

    I am not familiar with these scripts, but in general any modules must exist on the target Hyper-V server.
    The commands do not appear to be suing SCVMM, in which case you would execute the PowerShell script at the VMM console machine.
    Brian Ehlert
    http://ITProctology.blogspot.com
    Learn. Apply. Repeat.

  • Using Powershell to set Multiple timed.servers with variables

    Having an issue using PowerShell to set 3 timed.servers which are defined in a variable. Running the commands: $TimeServers = "IPaddress1,IPaddress2,IPaddress3"Set-NaOption -OptionName timed.servers -OptionValue $TimeServers Thanks in advance!

    Hi, The Set-NaOption CmdLet -optionvalue parameter expects a string and it shouldn't matter if that's a comma delimited string containing multiple IP Addresses. I noticed that whilst the cmdlet thows an error it does actually set the option value for all servers so this seems like it could be a bug (IMO). It might be possible to invoke the API using "Invoke-NaSystemApi" but I checked the ZAPI and noticed this also fails using ZExplore from the SDK: ZAPI Request: <?xml version="1.0" encoding="UTF-8"?>
    <netapp  xmlns="http://www.netapp.com/filer/admin" version="1.21">
      <options-set>
        <name>timed.servers</name>
        <value>192.168.100.10,192.168.100.11,192.168.100.12</value>
      </options-set>
    </netapp> ZAPI Results: <?xml version='1.0' encoding='UTF-8' ?>
    <netapp version='1.1' xmlns='http://www.netapp.com/filer/admin'>
        <!-- Output of options-set [Execution Time: 8610 ms] -->
        <results reason='Unable to set option: timed.servers' errno='13001' status='failed'>
            <cluster-constraint>same_preferred</cluster-constraint>
            <cluster_constraint>same_preferred</cluster_constraint>
            <message>1 entry was deleted.
    </message>
        </results>
    </netapp> So i think the options are either using the "Set-NaOption" cmdlet with the -SilentlyContinue parameter or the "Invoke-NaSsh" cmdlet with -ErrorAction stop.As a work around i'd recommend something like: [String]$servers = "192.168.100.10,192.168.100.11,192.168.100.12"
    [String]$command = "options timed.servers $servers"
    Try{
       Invoke-NaSsh -Command $command -ErrorAction Stop
       Write-Host "Executed Command: $command"   
    }Catch{
       Write-Warning -Message $("Failed Executing Command: $command. Error " + $_.Exception.Message)
    } Hope that helps /matt

  • Set default quota for farm using powershell

    Hello, 
    Looking for a powershell solution to creating a default quota template. So when new sites are created they default to that quota, or can be changed if needed. 
    Thanks, 
    Will 

    This article is for 2010, but it should work the same in 2013.  This PowerShell just creates the quota template.  You will need to pick the quota template when creating a site collection.  There is no way to set a default quota template for
    regular site collections.
    http://www.sharepointdiary.com/2013/08/create-sharepoint-quota-templates-using-powershell.html
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • How to set Current quota template dropdownto 50 GB using powershell script

    In central administrator under Application Management -> Configure quotas and locks  we have Current quota template drop down. I  want to set drop down value to 50 GB using powershell . Is it possible and it if it possible then How ? Please
    let me know 
    Thanks in Advance 
    Regards
    Subhash
     

    Hi Sub_84,
    A quota template consists of storage limit values that specify the maximum amount of data that can be stored in a site collection. When the storage limit is reached, a quota template can also trigger an e-mail alert to the site
    collection administrator. You can create a quota template that can be applied to any site collection in the farm. The storage limit applies to the sum of the content sizes for the top-level site and all subsites within the site collection.
    You can create quota template using powershell, ojbect module and sharepoint UI.
    Create new Quota template using powershell:
    $newQuotaTemplate = New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
    $newQuotaTemplate.Name = "New Quota Template"
    $newQuotaTemplate.StorageMaximumLevel = (150 * 1024) * 1024
    $newQuotaTemplate.StorageWarningLevel = (100 * 1024) * 1024
    $newQuotaTemplate.UserCodeMaximumLevel = 300
    $newQuotaTemplate.UserCodeWarningLevel = 300
    $contentService =[Microsoft.SharePoint.Administration.SPWebService]::ContentService
    $contentService.QuotaTemplates.Add($newQuotaTemplate)
    $contentService.Update()
    Check the link which can guide you how
    http://www.c-sharpcorner.com/uploadfile/anavijai/quota-templates-in-sharepoint-2010/
    Please mark the Answer and vote me if you think that above solution can help you to resolve the issue

Maybe you are looking for

  • Adobe TV videos won't play on iPad

    Hi all, I'm posting this here as well as having updated another post on the Adobe TV forum - it looks like there's more activity here. There are reports (mine among them) that the Adobe TV site doesn't work on some iOS devices.   I have an iPad 2, an

  • Some Sent messages are missing

    My wife has noticed that about 5-10% of the emails she sends are not in the Sent folder. When we checked the Console it gives the following error: Error (null) occurred while trying to append messages to outgoing store. Ignoring and proceeding delive

  • Bought 1.5 year old used macbook pro

    The hard drive is too small and i need to get a bigger one. I'm a pc convert. Can I buy any new 2.5 drive? Is it a sata drive? How do i find out? Thanks Larry

  • Corrupt Helvetica Italic font

    I have a corrupt Helvetica Italic font (Helvetica non-italic is fine). I reinstalled the OS and updated it - no change. Anyone have a fix? I'm running 10.4.5. - Doug G4 Powerbook   Mac OS X (10.4.5)  

  • Track on user activity

    I have root user access on the system, We have another user and our consultants are using that user for upgrading. I woluld like to keep records /track on all of thier commands. What is the best way? OS: zLinux, SuSE Liunx Enterprise Server 10 thanks