PowerShell Script for updating accounts in CSV

Hi Experts...!!!!
I need to have a power shell script that can update the status(Enable/disable) accounts given in a .csv file with DNs of the user accounts in it....
Any suggestions...
Thank You... 
TechSpec90

I recommend that you start by searching for answers:
This comes up as the first item in a search:
https://technet.microsoft.com/en-us/library/ee617200.aspx
\_(ツ)_/

Similar Messages

  • Powershell script for security groups and users for multiple share folders

    Hi scripting team,
    I need your help with powershell script for the below queries 
    1. List out the security groups for more than one server share path and output it to a file ( csv ) 
    For eg.
    If the are are two share paths 
    \\servername\foldermain\folder1
    \\servername\foldermain\folder2
    So I needs the list of security groups for each share path
    And the output needs to be under each any every path.
    2. Grab the users belongs to main security groups and it nested groups for more than one security group and listed the users under each and every group. No need to display nested groups. Just users belongs to main group and users under nested.
    Your teams help is much appreciated 
    Thank you.
    Thilochana kumararatne

    Hi Braham,
    Thanks for your quick reply.
    Are we able to do this on two stage method
    1. grab the security groups from the share paths
    if can grab the share path from a separate txt file than copying it to the <your path> location
    so i can modify the txt file
    once run the script
    if can the output like below to a CSV file
    \\servername\foldermain\folder1group 1group 2group 3\\servername\foldermain\folder2group 1group 2group 3then i know which groups belongs to which share paththen i can remove the duplicate groups and keep the common groups to grab the users belongs to itso with the second script same as the first copy the security groups to a txt file and the out put as below.what I needs is the users full name and the samaccount name ( user id )group 1user1user2user3
    group 2user1user2user3looking forward your help on thisThank you.Thilo

  • Powershell Script to Update Central PolicyDefintions Store against the local machine

    Hi all,
    i've created a powershell script to update my central policydefinitions store against a local machine for example the newest domaincontroller or member server. It can be started with the parameters -source (for the source directory e.g. C:\Windows\PolicyDefinitions)
    and -destination (for the target directory e.g. C:\Windows\SYSVOL_DFSR\sysvol\domain.local\Policies\PolicyDefinitions).
    It checks the source directory for language folders and admx files. Compares the Fileage with the files in the target directory and allows you to replace them. Maybe this script is helpful for one of you and maybe someone can check it and give me some feedback
    to make this script better.
    Please be very careful with this and try it on your own risk. You should try it in a testenvironment first. Or e.g. against an empty target directory. In the first version the script asks for confirmation for every single change against the target directory.
    You can find it here: http://pastebin.com/dwJytWck
    Regards

    Hi,
    You may also want to add this script to the script repository:
    https://gallery.technet.microsoft.com/scriptcenter
    That'll make it easier for more people to find.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • SAP VB script for updating texts in purchase orders

    Hello,
    I am trying to create a SAP script for updating texts in purchase orders. It is in the last third - Item Detail,  Texts tab.
    The script is ok apart from the fact that it always deletes whatever text is in there and than add a new one.
    I would like to keep history in the texts tab and always just add one line to existing texts. Is there any way (command) how
    to keep existing texts and only add a new line to the top?
    Thanks a lot!
    Jan

    Yes, you are exactly right. I have already figured it out as well. I did not expect it would be that easy. But thanks a lot anyway for replying on this!
    Now I am struggeling with changing SAPLMEGUI in vb scripts for ME22n. Sometimes, there is SAPLMEGUI:0010 and sometimes SAPLMEGUI:0015. Even when the users have the same screens in the beginning the SAPLMEGUI number differs. They also do one item by hand and than it changes. It keeps changing between SAPLMEGUI:0010 and SAPLMEGUI:0015
    Is there a way how to have the same number of SAPLMEGUI or how to eliminate this issue?
    Thanks a lot
    Jan

  • Executing a powershell script for checking duplicate users while creating a AD user throug ADUC console.

    Hi,
    I have a text file in which some SamAccountNames are present.I need to check the file while creating a new users through ADUC console.If a username that is going to create through ADUC console is present in the file, then it should prompt a message
    that the user is already present in the text file.
    Is there any possibility of contacting the powershell script from the ADUC console.If so, then while creating a new user through ADUC console, what is the proceedure for executing that powershell script.
    please provide me the approriate solutions.
    Thanks
    Prasanthi k

    Run the below Powershell Script for users are exist or not in AD. Later you can create the users.
    #Find Users exist in AD or Not?
    #Biswajit Biswas
    $users = get-content c:\users.txt
    foreach ($user in $users) {
    $User = Get-ADUser -Filter {(samaccountname -eq $user)}
    If ($user -eq $Null) {"User does not exist in AD ($user)" }
    Else {"User found in AD ($user)"}
    Active Directory Users attributes-Powershell
    http://gallery.technet.microsoft.com/scriptcenter/Getting-Users-ALL-7417b71d
    Regards~Biswajit
    Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights.
    MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, MCTS, Enterprise Admin
    MY BLOG
    Domain Controllers inventory-Quest Powershell
    Generate Report for Bulk Servers-LastBootUpTime,SerialNumber,InstallDate
    Generate a Report for installed Hotfix for Bulk Servers

  • Ola script for update stats only

    I want ola scripts for update stats only but on internet they are rebuilding index as well.
    http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
    Thanks

    By default index rebuild will gather index stats.
    If you just need a script update index and column statistics you can refer the below link
    http://www.sqlusa.com/bestpractices2005/administration/updatestatistics/
    You can refer same ola script to update the stats
    http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html
    C. Update statistics on all user databases
    EXECUTE dbo.IndexOptimize
    @Databases = 'USER_DATABASES',
    @FragmentationLow = NULL,
    @FragmentationMedium = NULL,
    @FragmentationHigh = NULL,
    @UpdateStatistics = 'ALL'
    D. Update modified statistics on all user databases
    EXECUTE dbo.IndexOptimize
    @Databases = 'USER_DATABASES',
    @FragmentationLow = NULL,
    @FragmentationMedium = NULL,
    @FragmentationHigh = NULL,
    @UpdateStatistics = 'ALL',
    @OnlyModifiedStatistics = 'Y'
    --Prashanth

  • Powershell script to update mailbox search

    I am trying to update a mailbox search using a powershell script:
    Stop-MailboxSearch -Identity "LitHolds" -confirm:$false
    $members = (import-csv -Path "Path"| ForEach-Object{$_.SamAccountName})
    foreach ($user in $members)
    Set-MailboxSearch -Identity "LitHolds" -SourceMailboxes $user.samaccountname
    Start-MailboxSearch -Identity "LitHolds" -confirm:$false
    I essentially have our sysadmins populating a csv file and then they run this script manually every night with the latest updates.  They are telling me that the mailbox search is empty.
    When I run the script I am getting a watson error immediately after with the following:
    WARNING: An unexpected error has occurred and a Watson dump is being generated: Value cannot be null.
    Parameter name: legacyDN
    Value cannot be null.
    Parameter name: legacyDN
        + CategoryInfo          : NotSpecified: (:) [Stop-MailboxSearch], ArgumentNullException
        + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.Tasks.StopMailboxSearch
        + PSComputerName        : Exchange Server Name
    What I don't understand is why it's looking for a legacyDN??
    Anyone able to do something similar?
    Chuck

    Hi Chuck,
    I would like to verify if you have a legacy Exchange.
    The LegacyDN property indicates the legacyDN of the mailbox and matches the legacyExchangeDN attribute of the user object in  Microsoft Active Directory.
    If there is any update, please feel free to let me know.
    Best regards,
    Amy
    Amy Wang
    TechNet Community Support

  • Using Echo Command in PowerShell Script for Configuration Item

    Hello All,
    Before you tell me to post my PowerShell question to the PowerShell Forum, please know that the PowerShell portion of my task works just fine. It is the SCCM portion of my task that keeps failing, so that is why I am here. To give some background...
    There are two servers in our SCCM test environment. Both the SCCM server and SQL DB server are 2012, patched and updated.
    Test servers in my Device Collection being used for running Baselines and Reports against are 2008R2 and 2012, patched and updated.
    I have created a Configuration Item that checks to see if the FTP Server Role Feature has been installed on a 2008 or 2012 server. To do the check, I am using the following PowerShell script:
    (get-windowsfeature -Name Web-Ftp-Server).Installed
    When I log into my 2008R2 and 2012 test servers, and run this command directly on the server, it will return a "True" if the FTP Server Role Feature is installed on either server, and a "False" if it is not installed. Basically,
    it works as advertised.
    When I setup my Configuration Item and then deploy my Baseline, or run a report against my device collection of test servers, SCCM will return a correct response (True or False) for the 2012 test server, but throws the following error for the 2008R2
    server:
    0x87df00329 application requirement evaluation or detection failed
    Google searches for this have not been very helpful.
    Now, when I created the Configuration Item and referenced PowerShell, the configuration screen has the following note:
    "Specify the script to find and return the value to be assessed for compliance on client devices. Use the echo command to return the script value to Configuration Manager."
    Since I did not include an echo command in my PowerShell script above, I figured that was my problem, so I did the following:
    Logging onto both of my test servers (2008R2 & 2012) I was able to successfully run the following PowerShell commands and get the expected responses of True or False:
    (get-windowsfeature -Name Web-Ftp-Server).Installed | echo
    (get-windowsfeature -Name Web-Ftp-Server).Installed | write-output (http://technet.microsoft.com/en-us/library/hh849921.aspx)
    (get-windowsfeature -Name Web-Ftp-Server).Installed | write-host (http://technet.microsoft.com/en-us/library/ee177031.aspx)
    However, when I use any of these PowerShell commands in my Configuration Item, NEITHER of my test servers returns a response to the SCCM server.
    When I check the report, both servers show as "Unknown" and when I click on the number 2 (as in 2 servers unknown), the following report page (List of unknown assets for a configuration baseline) has absolutely no data/information at all.
    So...I am at a loss.
    SCCM tells me to use an echo command to return a script value to Configuration Manager. The PowerShell scripts above, with the various echo related commands, work just fine on the servers themselves, but they return no information when run via SCCM.
    What am I missing?
    Any help will be appreciated.
    Thanks in advance for your time.

    Sorry for my ignorance, but I don't understand. (I forgot to mention that I am new at both PowerShell and SCCM.)
    After I change the PowerShell script to add the echo/write-output/write-host cmdlet, I open the ConFig Item and "Clear" the PowerShell script and then re-add it. When I do that, it correctly shows the change in the ConFig Item.
    Next I open the Baseline, then open the ConFig Item within the Baseline to make sure the change is reflected there as well, which it is.
    I then deploy the Baseline to my Device Collection. After that, I run a report against the Baseline and Device Collection and it returns the "Unknown" result.
    If I open the PowerShell script and remove the echo/write-output/write-host cmdlet, then go through the rest of the process of updating and reporting, the result it returns changes, showing one server in compliance and the other server out of compliance,
    which leads me to think that all changes have taken correctly.
    Does that sound right? If I manually deploy the Baseline, is that the same as the client retrieving policies from the management point?
    Sorry to be so thick but I'm learning as I go.
    Thanks again for your help.

  • PowerShell Script for Setting the Welcome Page View of a document set

    Hi,
    We are using document set in the document library and we have created the separate view in the document set and it will show only particular metadata columns. We need to change from default view to another view. For this, we need to write the power shell
    script and update the document set welcome page view link in the document set template. Please let me know how we can get this.
    Thanks,
    Mylsamy

    Hey Mylsamy,
    welcome page view is stored in $contenttype.XmlDocuments. Here is how you can change the view using powershell:
    $web = Get-SPWeb "WEBURL"
    $list = $web.Lists["LISTNAME"]
    $contenttype = $list.ContentTypes["CONTENTYPENAME"]
    $viewid = $list.Views["VIEWNAME"].Id
    $xmldocs = $contenttype.XmlDocuments
    foreach($xmldoc in $xmldocs)
    if($xmldoc.Contains("WelcomePageView"))
    Write-Host "XML contains WPV"
    $newview = [XML] @"
    <wpv:WelcomePageView xmlns:wpv="http://schemas.microsoft.com/office/documentsets/welcomepageview" ViewId="$viewid" />
    $xmldocs.Delete("http://schemas.microsoft.com/office/documentsets/welcomepageview")
    $xmldocs.Add($newview)
    break;
    $contenttype.Update($updateChildren, $false)
    Write-Host "Welcome Page View updated at " $list.Title
    Regards,
    Alexander 

  • FIM Reporting ETLScript PowerShell Script for SCSM 2012?

    Hi,
    The FIM Reporting Deployment Guide is great, however on a few occasions it forgets to mention where you meant to execute things (http://technet.microsoft.com/en-us/library/jj133855(v=ws.10).aspx) .
    For example, if it wasn't for the screenshot in the article, we would not have known that we need to run the ETLScript from the FIM Service/Portal server.
    Everything until the ETLScript has thus far worked; and we have deployed the Service Manager 2012 console on the FIM Service/Portal server (since we are using SCSM 2012 for FIM Reporting).
    However, it appears that the ETLScript (in the deployment guide) has been written for SCSM 2010.
    So, has Microsoft or anyone published an updated SCSM 2012 ETLScript script?
    Thanks,
    SK

    Could this be it?
    http://gallery.technet.microsoft.com/PowerShell-Script-to-Run-a4a2081c

  • Powershell script for mailbox permissions

    Hello,
    Part of my tasks as an Exchange admin is to give access to shared mailboxes. The access usually are:
    Send AS
    Receive As
    Send on Behalf Of
    Full mailbox
    Is there a powershell script out there that does all of the above?
    thanks,
    Alexis

    Hi,
    Probably not prewritten, but you can check the repository for starters:
    http://gallery.technet.microsoft.com/scriptcenter
    EDIT: I should mention - this isn't too hard to write, so this could be a good opportunity to learn how to get around in the EMS.
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Powershell script for deleting sitecollection and its content db

     want to know whether any powershell script is avlble for deleting the sitecollection and its content db at oneshot!
    i have created sitecollection specific content db and i wanna delete the same.

    Hi,
    Below link will help to delete site collection
    http://technet.microsoft.com/en-us/library/cc262392(v=office.15).aspx
    Thanks
    Somnath Matere

  • Powershell script for removing some users from a particular Site Collection

    Hi,
    I am looking for a PowerShell script to delete a few users from a particular Site Collection. I am unable to delete them from/_catalogs/Users/simple.aspx page therefore need some other medium to
    delete users from the site collection.
    My ultimate aim is to have no user profile with "tp_deleted" field's value as 0 in the USERINFO table. Currently there are about 40 odd users with this field's value as 0 and this is affecting my crawling of this content database.

    Thanks for the reply Alex & eHaze,
    I have a content source of root site which crawls all the site collections under it. Out of the 9 site collections, only 8 are getting crawled and 1 doesn't get crawled at all. The error in the crawl logs is 
    The SharePoint item being crawled returned an error when requesting data from the web service. ( Error from SharePoint site: Value does not fall within the expected range. )
    I tried a lot of things, searched over the net and finally found
    this which helped me solve the same issue in my development environment. I deleted these users from userInfo table and ran a full crawl. And the issue was fixed.
    Now since I cannot delete the users from userInfo table directly from PROD environment, I used .../_catalogs/Users/simple.aspx list
    to delete users from this site collection. While some of the users I could delete, quite a few I could not. Clicking on the profile redirected me to the home page rather than the info page of the profile. 
    This
    is why I have to delete these users from the site collection.
    Alex - the link you shared, I guess it is for a web application level.
    eHaze - the script you shared throws this error:
    Get-SPSite : Cannot find an SPSite object with Id or Url: http://dev-apps/divisions/BT. At C:\PowerShell Scripts\DeleteUserFromSiteCollection1.ps1:4 char:19
    + $site = get-spsite <<<< $siteURL
    + CategoryInfo : InvalidData: (Microsoft.Share...SPCmdletGetSite:
    SPCmdletGetSite) [Get-SPSite], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite
    You cannot call a method on a null-valued expression.
    At C:\PowerShell Scripts\DeleteUserFromSiteCollection1.ps1:9 char:27
    + $site.SiteUsers.Remove <<<< ($LoginName)
    + CategoryInfo : InvalidOperation: (Remove:String) [], RuntimeExc
    eption
    + FullyQualifiedErrorId : InvokeMethodOnNull
    hope this info helps.

  • Powershell script for Use this termset for site navigation in tem store management tool in central admin

    can anyone pls point out whats the power shell script for "use this  termset for site navigation" in the termstore management tool in my central  admin';s manage serv appln-->managed metadata serv appln ->term styore mgmnt tool
    i would like to check this "checked" through powershell script
    help is appreciated!

    Hi,
    To check if the term set has been set to be used for site navigation, we need to check the
    NavigationTermSet.IsNavigationTermSet property for the term set.
    Here is the code example for using PowerShell to get the setting:
    $site=Get-SPSite "your site collection URL";
    $session = Get-SPTaxonomySession -Site "your site collection URL ";
    $termStore = $session.TermStores["Managed Metadata Service"];
    $Group = $termStore.Groups[“Group Name”];
    $TermSet = $Group.TermSets[“Term Set Name”];
    $navTermSet = [Microsoft.SharePoint.Publishing.Navigation.NavigationTermSet]::GetAsResolvedByWeb($termset, $site.RootWeb, "GlobalNavigationTaxonomyProvider");
    write-host $navTermSet.IsNavigationTermSet
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • PowerShell script to update quick launch navigation.

    Hi,
    We recently did some reorganization, which involved nesting some sites within others.  Some of these sites were based on a custom template, and as a consequence, the quick launch URLs, although relative, did not update.  I found some potentially
    useful PowerShell script, from
    here. 
    function Repair-SPLeftNavigation {
    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$true)][System.String]$Web,
    [Parameter(Mandatory=$true)][System.String]$FindString,
    [Parameter(Mandatory=$true)][System.String]$ReplaceString
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $SPWeb = Get-SPWeb $Web
    $SPWeb.Navigation.QuickLaunch | ForEach-Object {
    if($_.Url -match $FindString){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $_.Children | ForEach-Object {
    if($_.Url -match $FindString){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $SPWeb.Dispose()
    The problem I see is that the original URL string is '/data/studysites/site' and the replacement URL is '/researchers/data/studysites/site', and it looks like this script would go through and repair the incorrect links while
    breaking the correct ones.
    I'm trying to use the -like operator instead of the -match operators to match the $FindString based on a URL that
    begins with '/data/studysites/site' rather than contains it, which should (I'm thinking) exclude correct links (which already start with '/researchers.').  This isn't going well though.  I am guessing I don't understand how to use the -like
    operator with wilodcard variables.  Here's what I came up with.
    function Repair-SPLeftNavigation {
    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$true)][System.String]$Web,
    [Parameter(Mandatory=$true)][System.String]$FindString,
    [Parameter(Mandatory=$true)][System.String]$ReplaceString
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $SPWeb = Get-SPWeb $Web
    $SPWeb.Navigation.QuickLaunch | ForEach-Object {
    if($_.Url -like '$FindString*'){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $_.Children | ForEach-Object {
    if($_.Url -like '$FindString*'){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $SPWeb.Dispose()
    }#endFunction
    Help much appreciated!

    Hi Mike,
    Tried that, and in that case, it didn't seem to do anything.
    function Repair-SPLeftNavigation {
    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$true)][System.String]$Web,
    [Parameter(Mandatory=$true)][System.String]$FindString,
    [Parameter(Mandatory=$true)][System.String]$ReplaceString
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $SPWeb = Get-SPWeb $Web
    $SPWeb.Navigation.QuickLaunch | ForEach-Object {
    if($_.IsExternal -AND $_.Url -like "$FindString*"){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $_.Children | ForEach-Object {
    if($_.IsExternal -AND $_.Url -like "$FindString*"){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $SPWeb.Dispose()
    I ran the script, adding the -verbose flag, and got this:
    PS C:\Scripts> Repair-SPLeftNavigation -Web http://loki/researchers/data/WHIStudies/StudySites/ -FindString "/data/WHIStudies/StudySites" -ReplaceString "/researchers/data/WHIStudies/StudySites" -Verbose
    VERBOSE: Leaving BeginProcessing Method of Get-SPWeb.
    VERBOSE: Leaving ProcessRecord Method of Get-SPWeb.
    VERBOSE: Leaving EndProcessing Method of Get-SPWeb.
    PS C:\Scripts>
    I then tried expanding the quotes to include the whole IF statement:
    function Repair-SPLeftNavigation {
    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$true)][System.String]$Web,
    [Parameter(Mandatory=$true)][System.String]$FindString,
    [Parameter(Mandatory=$true)][System.String]$ReplaceString
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $SPWeb = Get-SPWeb $Web
    $SPWeb.Navigation.QuickLaunch | ForEach-Object {
    if("$_.IsExternal -AND $_.Url -like '$FindString*'"){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $_.Children | ForEach-Object {
    if("$_.IsExternal -AND $_.Url -like '$FindString*'"){
    $linkUrl = $_.Url
    Write-Host "Updating $linkUrl with new URL"
    $_.Url = $_.Url.Replace($FindString,$ReplaceString)
    $_.Update()
    $SPWeb.Dispose()
    This got me the following error.  It seems it is trying to "fix" some URLs that don't need fixing, but not fixing those that do. :)
    Updating /researchers/data/WHIStudies/StudySites/AS297 with new URL
    Exception calling "Update" with "0" argument(s): "Cannot open "/researchers/researchers/data/WHIStudies/StudySites/AS297": no such file or folder."
    At C:\Scripts\Repair-SPLeftNavigation.ps1:15 char:9
    + $_.Update()
    + ~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SPException
    Thanks!
    Josh

Maybe you are looking for