Run a powershell script with domain credentials during task sequence

I have a powershell script that adds the computer it is run on to a security group.  If I log onto the computer with a domain account it works perfectly.  However, if it is run while logged on as the local admin account it fails with an error message
that says the domain either doesn't exist or cannot be reached.
This is a problem because when a computer is being imaged the process runs with the local admin account.  Is there a way to run this script with domain credentials in the task sequence?
Thanks,
Andy

How are you running the Powershell script? If you use a Run Command Line step, you can specify an account to run as. Something like "powershell %scriptroot%\psscript.ps1" where the psscript.ps1 is located in your Scripts folder in your deployment
share.
-Nick O.

Similar Messages

  • What is the best way to run a powershell script with parameters in the Task Scheduler?

    Hello, 
    Want to run the following from a scheduled task in the Task Scheduler on a server.  What is the best approach?
    .\pscript.ps1 -csvfile "\\Srv1\Share\File.txt"
    Thanks for your help! SdeDot

    Hi,
    To run a powershell script with parameters in the Task Scheduler:
    Program: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add argument (optional): -Command "& c:\scripts\test.ps1 -par1 2 -par2 3"
    Hope the below two articles be helpful for you:
    Schedule PowerShell Scripts that Require Input Values
    https://blogs.technet.com/b/heyscriptingguy/archive/2011/01/12/schedule-powershell-scripts-that-require-input-values.aspx
    How to Schedule a PowerShell Script
    http://dmitrysotnikov.wordpress.com/2011/02/03/how-to-schedule-a-powershell-script/
    Regards,
    Yan Li
    Regards, Yan Li

  • Running a Powershell script via IIS on client machine

    Hello,
    I have a Powershell script that I want to serve to clients that will access my site.
    The script is simple - it will terminate Outlook and Communicator and restart in Cleanfreebusy mode.
    Researching this has noted that there is an IIS plugin that will allow the running of Powershell scripts?
    I would like to ask you, colleagues, is there a way I may be able to do this? That is to allow my clients run this Powershell script without downloading locally.
    Many many thanks,

    I have somewhat of a similar process, where I asked on the ASP.NET forums, as I needed my users of an Intranet site to be able to have a script run with the click of the button. I was told that it was not possible, as the browser is built to not allow stuff
    like this for security reasons.
    I haven't heard of a plugin so maybe there are other ways, but what I actually had to do, was create a batch file, and than on my webpage I added an IFrame
    <iframe id="myIframe" runat="server"></iframe>
    Than either in the html markup you can set the src attribute (I did mine in the code behind), to the directory where the file is at, so for instance \\myserver\fileishere
    Obviously the location needs to be shared and allow all users read/execute. This will display the file on the web page, and then the users, just double click it and it executes.
    You can possibly have a batch file that calls powershell and the script, but the script will need to be downloaded to the users machine, so it may be easier to find a batch equivallent of your powershell script and use DOS commands
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

  • Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?

    Which is better approach to manage sharepoint online - PowerShell Script with CSOM or Console Application with CSOM?
    change in sharepoint scripts not require compilation but anything else?

    Yes, PowerShell is great, since you can quick change your code without compilation.
    SP admin can write ps scripts without specific tools like Visual Studio.
    With powershell you can use cmdlets,
    which could remove a lot of code, for example restarting a service.
    [custom.development]

  • A way to run bundle tests scripts with EBS 11.5.10.2

    Hi,
    looking for a way to run bundle tests scripts with EBS 11.5.10.2. We prepare our tests scenarios and run them manually now but would rather job them and verify results of testing on logs created by the automatic execution of these scripts.
    We use UPK for preparing and supporting our training activities and I read that UPK features a way to prepare and run bundle tests scipts. Does anybody from the community knows something about that? I haven't found a guide to explain how to do it.
    Hoping someone to lead me to the topic I'm looking for. Does any release of UPK can do this and how or the community uses another tool to do so
    Alain

    UPK allows you to create manual test scripts which can be imported into a variety of testing suites. UPK does not provide automated test scripts. In the current release, the name of the publishing style is "HP Quality Center". This will create a spreadsheet document that can then be imported into a variety of testing suites as a test script. The product documentation should give you all the information you need to start using the HP Quality Center output. If not, here is a blog post describing how to use UPK to create an output for IBM Rational Quality Manager, which may help describe how this process works:
    http://blogs.oracle.com/UPK/2010/05/upk_and_rqm.html
    I hope this helps.
    Best regards,
    Marc

  • Installer launching command prompt that should run a powershell script and remain open

    I am using the Microsoft Visual Studio Installer Projects extension for VS 2013. This installer is designed to place a windows app in a directory and then launch a powershell script to prompt the user to sideload the application. From what I read online,
    you can make a windows console application and then add that .exe under the install custom actions to have the exe run after the installation is done. My installer is running the executable, but not in the way I want it to. This is the code that the console
    application has:
    static void Main(string[] args)
    Process.Start(@"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", @"-ExecutionPolicy bypass -NoExit -File Application\Add-AppDevPackage.ps1");
    One key thing to note here is the -NoExit. I want the prompt to remain open. If I run this console application directly, the powershell console does indeed stay open. You can see here where I have added the .exe as part of the install custom action.
    One additional thing to note is when I looked at the exe in the directory after the install, it is different than the one generated when I compile the console application project. I wouldn't know why the installer is physically changing the binary when I
    expect it to just copy the output from that compiled project/copy that file.
    If anyone has any additional input on how to make this process easier to have an installer (.msi) to place my windows app in a directory and run a powershell script to prompt the user to sideload it, then I welcome that too.

    Hello,
    I am afraid this issue is beyond the scope of our support.
    The current forum you posted to is used to discuss general issues about developing applications for Windows.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Access to ACS 4.2 with Domain Credentials

    Hello,
    We have ACS 4.2 for windows on an enterprise network. User authentication to network devices are passing through the acs via tacacs+ with domain credentials.
    Please, i need to know if is possible to also have access to the acs GUI with domain (windows) credentials. If possible, send documentations.
    Awaits your response.
    Regards,
    Ethelbert

    I think you mean that radius is working through ACS for domain users.  TACACS is used for device access.  Here is a link to guide you through the setup.
    Scott
    **Please rate helpful post**

  • OSD: install software DURING task sequence based upon collection membership

    Hi,
    I'd like to refer to my
    previous post as a starting point.
    Below again the background of my question. But please advise on a powershell script that runs at the end of a task sequence that:
    *enumerates the pc's collection memberships and based upon that lists the software available
    *puts this software in a variable and does the installation DURING the task sequence
    J.
    Background:
    At this time, software in our deployment (of Windows 7) is installed AFTER the task sequence is finished.
    The software is deployed based upon the computer membership of collections (which get their info from AD groups).
    Problem is that users see their pc as finished but don't have all their software. It even takes sometimes more then an hour even when we refresh computer policy after final reboot of the system. That's why we really need a bulletproof solution = installation
    of software DURING task sequence.
    Jan Hoedt

    I found some time to adjust the script. Now I've created something similar for a device. Basically it finds the collections of which the device is a member, finds the targeted applications and creates task sequence variables for those applications.
    See for more information:
    http://www.petervanderwoude.nl/post/install-computer-targeted-application-during-os-deployment-via-powershell-and-configmgr-2012/
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • How can we get the prompt to enter IP Address, Subnet Mask , gateway and DNS Server during Task Sequence?

    How can we get the prompt to enter IP Address, Subnet Mask , gateway and DNS Server during Task Sequence?

    This is for 2007 but may still be relevant for 2012
    http://hexdump.net/?p=391
    Cheers
    Paul | sccmentor.wordpress.com

  • I'm trying to run a scheduled task as system, but it will not run my powershell script

    I have a powershell script I created that uses credentials within the script to connect to a network resource to copy files every night. It works fine if I just run the script manually. but I need to run this as a scheduled task, preferably as system. I
    have checked "run with highest privileges" still no luck. 
    If I change the user to my account it works fine, but I need it to work without the use of my account. Is this some kind of security policy problem or what would cause this? I figure having the credentials within the script would work, but not so much.
    Paul Arbogast

    I have a powershell script I created that uses credentials within the script to connect to a network resource to copy files every night. It works fine if I just run the script manually. but I need to run this as a scheduled task, preferably as system. I
    have checked "run with highest privileges" still no luck. 
    If I change the user to my account it works fine, but I need it to work without the use of my account. Is this some kind of security policy problem or what would cause this? I figure having the credentials within the script would work, but not so much.
    Paul Arbogast
    Is the Execution Policy set for the script?
    With this information it sounds to be.....
    Take a look @
    http://technet.microsoft.com/en-us/library/ee176961.aspx
    Best Wishes,

  • Running a PS script with elevated privilages

    This is what I would like:User opens the script with PowerShellUser must enter password of domain admin (secure string)Script starts running as Domain AdminI have not been able to find any solution for this, 
    any help would be appreciated!

    Hello,Currently I have a batch script that moves files of a certain type from one folder to an archive folder with the current date. The script I use for this is:Batchfilefor /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%amkdir C:\ArchiveReportFiles\Archive\%date:/=%robocopy /E C:\eFinancials\report C:\ArchiveReportFiles\Archive\%date:/=% *.pdf /mov /minage:100 This works fine but it looks at the date modified not the date created so i still have files from over 2 years in there if somebody opened them by mistake, so I'm trying to recreate the the same script but using Powershell so I can use the CreationTime variable. I've got this:Powershell$dirname = "$((get-date).toString('dd-MM-yyyy'))"New-Item -ItemType directory -Path "C:\aa_Mine\test\PowershellTest\testto\$dirname"get-childitem -Path "C:\aa_Mine\test\PowershellTest...

  • Update a filed value with powershell script with ordery by and where condition

    Hi
    I have below powershell script to update list columns but  how i update a field value with ordery by a column and where condition
    below is the part of my script
    $list = $web.Lists[$listName]
    $items = $list.items
    $internal_counter = 1
    #Go through all items
    foreach($item in $items)
    if($item["CourtNO"] -eq $null)
    #if($item["CourtNo"] -eq '1')
    $item["CaseNo"] = $internal_counter
    #how to add a column ordery by Title
    # and where Title field value from 1 to 10
    $internal_counter++
    adil

    Hi,
    You mean that you only need to update all items with Title field value in range 1..10 and order by them before run the loop statement update?
    If so, use CAML query to get the items only match the condition.
    #Build Query
    $spQuery = New-Object Microsoft.SharePoint.SPQuery
    $query = '<Where><And><Gte><FieldRef Name="Title" /><Value Type="Text">0</Value></Gte><Lte><FieldRef Name="Title" /><Value Type="Text">10</Value></Lte></And></Where><OrderBy><FieldRef
    Name="Title"/></OrderBy>'
    $spQuery.Query = $query
    $spQuery.RowLimit = $list.ItemCount
    $items = $list.GetItems($spQuery)
    Hope this help!
    /Hai
    Visit my blog: My Blog | Visit my forum:
    SharePoint Community for Vietnamese |
    Bamboo Solution Corporation

  • Logging on to Win 8.1 workstation with domain credentials

    Hi All.
    I been on Windows 8 Pro(now 8.1 update 1) for over a year now. Until now, I've always logged on to my workstation with my MS account. I recently decided to join my workstation to a domain where the Primary DC is running Server 2008 r2. I joined the domain
    without a hitch, but when I try to log on to the workstation using domain credentials, the logon screen seems to insist on a MS account. It wants user name to be in email form only. When I tried to use my domain credentials in that format ([email protected])
    it told me that the password is wrong and I should make sure to use my MS account password.
    I tried disconnecting my MS account from my local account, but it didn't help.
    Any ideas?

    I'm not sure if what you are doing is supported, to have a local MS sign-in account as well as a corporate domain account residing side by side, you might have to give up your MS sign-in and use a local ID for the domain logon to work
    you may however consider setting this up using the Workplace Join feature in 8.1 which should work much better
    http://blogs.technet.com/b/keithmayer/archive/2013/11/08/why-r2-step-by-step-solve-byod-challenges-with-workplace-join.aspx

  • How can I setup a scheduled task to run a Powershell Script delivered as a Group Policy Preference

    I have a Powershell script I want to run only once when a user logs onto their system. This script would move all the PST files from the Local drive and the Home drive to a folder location within the users profile. I wanted to run this as a Windows 7 Scheduled Task using Group Policy Preferences. How can I get this to happen short of a logon script? I have updated all the machines to WMF 4.0 so could I use a Scheduled Job instead? I wanted to run the script as the logon user but elevated.#Start Outlook and Disconnect attached PST files.
    $Outlook = New-Object -ComObject Outlook.Application
    $namespace = $outlook.getnamespace("MAPI")
    $folder = $namespace.GetDefaultFolder("olFolderInbox")
    $explorer = $folder.GetExplorer()
    $explorer.Display()
    $myArray= @()
    $outlook.Session.Stores | where{ ($_.FilePath -like'*.PST') } | foreach{[array]$myArray+= $_.FilePath}
    for
    ($x=0;$x-le$myArray.length-1;$x++)
    $PSTPath= $myArray[$x]
    $PST= $namespace.Stores | ?{$_.FilePath -like$PSTPath}
    $PSTRoot= $PST.GetRootFolder() #Get Root Folder name of PST
    $PSTFolder= $Namespace.Folders.Item($PSTRoot.Name) #Bind to PST for disconnection
    $Namespace.GetType().InvokeMember('RemoveStore',[System.Reflection.BindingFlags]::InvokeMethod,$null,$Namespace,($PSTFolder)) #Disconnect .PST
    #Move All PST files to the default location while deleting the PST files from their original location.
    $SourceList = ("$env:SystemDrive", "$env:HOMEDRIVE")
    $Destination = ("$env:USERPROFILE\MyOutlookFiles")
    (Get-ChildItem -Path $SourceList -Recurse -Filter *.PST) | Move-Item -Destination $Destination
    #Attach all PST files from the default location.
    Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
    $outlook = new-object -comobject outlook.application
    $namespace = $outlook.GetNameSpace("MAPI")
    dir “$env:USERPROFILE\MyOutlookFiles\*.pst” | % { $namespace.AddStore($_.FullName) }

    Mike,
    I do not understand what appears to be a regular expression above. I did add the PowerShell script to the HKCU RunOnce Key as suggested.
    Windows Registry Editor Version 5.00
    C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -sta -WindowStyle Hidden -ExecutionPolicy RemoteSigned -File "C:\scripts\Windows PowerShell\Move-PST.ps1"
     I'm delivering this using Group Policy Preferences. It seems to fail or time out when run because the behavior is different if I run the script from within the PowerShell IDE. I added the parameters to the script and will try it again in the morning.

  • Run a powershell script on every user login/unlock

    Hi everybody
    I need to run a powershell (that opens an interactive dialog box) when every user log in or unlock session or remote connection to this server.  In other words it have to be run every time a user enters a credential. 
    I tried task scheduler, but it didn't work properly. I tried triggers like "on workstation unlock" and "on connection to user session". I change user and group to administrators but still it runs under the author user (me) . 
    I found out user login event id is 4801 and 4778. can I use these event ids to run powershell code? Can I check raising the event ids through my code? 
    any other idea please?
    Thanks in advance

    Im not going to block a logon! I want to run a powershell code for every user login. assume like a message after user login. this kind of message for me is showing to me after other users login.
    specifically this is a window from that I designed to execute on user login to show on the server and every user writes down in the text box the changes that is making on the server. this is a changes log solution to me. then I need to show every user to
    work properly.
    You can run a scheduled task at logon that can display a message.  You can define this task in Group Policy.
    You can also just use the standard user logon message which can also be defined in Group Policy.
    You can execute a script task whenever an unlock event happens.  This, too, can be defined in Group Policy.
    ¯\_(ツ)_/¯

Maybe you are looking for

  • How can I display data gathered in a subVI in a graph of the main VI?

    I have written a largish application (~50 VI's) which acquires, analyzes, display and saves data from an instrument with a built-in DAQPad. My problem is that my block diagram is rather messy by now. I'm using an event structure in my main VI which r

  • Oracle 10g Enterprise Manager Console bug?

    I think I have come across a bug in the Oracle 10g Enterprise Manager Console. If I go into my database, then into the schema, select your schema from the list, then tables. Now once your in your tables, find one that you know of and know fairly well

  • ITunes refuses to check for App updates! Any idea why?

    I'm having what seems to be a strange problem. I have iTunes 11.0.1, with apps I have downloaded on my machine. Regardless of an iPad, iPod or iPhone attached, clicking on the "Check for Updates" button will NOT work. At all. I get app update alerts

  • Time from UNIX epoch

    I have the number of micro seconds from the UNIX epoch time 00:00:00 UTC 1 Jan 1970. (1092727073895638 usec) I want to know the time in CST. I have been trying to work with the Calendar class and GregorianCalendar. But I am not quite getting it. Coul

  • The efficiency of oci program with OCI_COMMIT_ON_SUCCESS

    I have write a demo program to insert 1000 row data into a tab. As I want to commit at every insert operation, I call OCIStmtExecute with OCI_COMMIT_ON_SUCCESS parameter. And the time cost for each row is between 5ms and 10 ms. At the same time, inse