Windows Image Deployment - WinPE - Execute Command After Server Image Deployment but Before WinPE Reboot

Simplified version: Execute command in WinPE after server image deployment but before WinPE reboots.
I have a custom ISO with a boot.wim and install.wim for deploying Windows Server to our environment. Our environment does not allow DHCP and we have no static IPs available at build time so this will all be done with no internet connection during all phases
of deployment.
We have a custom HTA form that generates an XML file based on user input and stores it on the RAMDisk during WinPE. How can we move this XML file from the RAMDisk to the deployed Windows Server image?
Thanks in advance, Tim

I believe you should be able to do this during the offlineServicing configuration pass.  You would just need to add into your answer file a command or script to copy from the XML file over to the newly created C:\ drive.  
I don't have System Image Manager installed on the computer I'm using but if I recall there is a spot during the offlineServicing pass to execute custom commands. You would just add your script path there, the WinPE system drive letter is
X:\ , and I think the target drive letter Windows is installed to might change depending on how many devices you have hooked up so do a test install and hit SHIFT-F10 , from there you can run diskpart > list volume to see where the new Windows
install is located. 
Another alternative could be using a USB drive as your install media, then you can run a script during offlineServicing to copy that XML over to the USB drive.

Similar Messages

  • SUBMIT an ABAP report after creating the WI but before completion of WI.

    Dear All,
    I am having an activity which sends the approval work item.
    Now my requirement is to SUBMIT an ABAP report after creating the WI but before completion of WI.
    I can not call this report before approval activity because i need to pass this WI ID to this report.
    Please suggest some way to solve this.
    Regards,
    Amar

    Hello,
    You could create a 2-from-2 fork and put the workitem in one branch and the report in the other. Have the report branch wait 1 minute and then read the workitem id from the other branch.
    What is the purpose of this report? Why does it need the workitem id?
    regards
    Rick Bakker
    hanabi technology

  • Executing 2nd command after server rebooted & related services started

    hi friends
    i am creating a PS script containg two lines:
    the first line executes dcpromo /unattend:c:\answerfile.txt to create a new domain controller
    the second line will disable domain password complexity which is: 
    set-executionPolicy -identity mydomain.lab -complexityenabled $false -minimumpasslength 5
    the problem is i need after first line of the script, executed, server be rebooted & the 2nd line 
    be executed after server rebooted & whey AD services started, this script continue to run the next line.
    is it ossible in powershell?
    thanks in advanced

    You won't be able to do that in the same script.
    You can use a second script that waits for the AD services to start, and then sets the password policies and run that script after the restart using the RunServicesOnce key:
    https://support.microsoft.com/kb/179365?wa=wsignin1.0
    Use the first script to set that key and then do the restart after the DC promo is finished.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    hi again. thanks
    in addition i found that the powershell workflow is better way to that
    regards

  • Windows 7 won't shut down after I close firefox, but if I sign on to internet explorer and then shut down windoes 7 will shut down properly. Whats up?

    Latlely when I attempt to shut down my Hp Pavilion dv6 3230 us Laptop it goes through the normal process I believe, however, the screen shows "shutting down" but it will show the screen forever until I plug out the power supply. All of the keys and combinations of keys are inoperable including the mouse.
    If I sign on to Internet Explorer after I sign out of Firefox, and then sign out of Internet Explorer the Laptop will shut down successfully.

    Firefox Hang at exit
    https://support.mozilla.com/en-US/kb/Firefox%20hangs#w_hang-at-exit
    Check and tell if its working.

  • Do any apps work in the background during/after an ios update, but before the update is completed? Specifically 'find my friends'

    ?

    You may need to try recovery mode.
    Link to info:  http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    INSTRUCTIONS:
    Try and force the iOS device into Recovery Mode:
    1. Turn off device
    2. Connect USB cable to computer; leave the other end alone
    3. Press and hold the Home button down and connect the docking end of cable to device
    4. Continue holding the Home button until you see the "Connect To iTune" screen
    5. Release the Home button
    6. Open iTune
    7. You should see "iTunes has detected the device in recovery mode"
    8. Use iTune to restore device
    Note: You need to be patient and repeat the above many times to recover your device

  • Windows Search Service Best Pratices on RDP Server with office 2013

    high everybody,
    i´m looking for guide how to configure the Windows Search Service on our Server 2012 RDS Servers. The Servers have Office 2013 installed so turning off the Search Service is not an Option. We are using User Profile disks and logoff was getting slower
    as time goes by. Reading in another thread if have deleted the Subkeys under
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules
    and restarted the Search Service.
    This Resulted in a lighning fast logoff ( less then 5 Seconds) before that logoff took up to 2 Minutes. Looking at the Reg Key´s i found that underneth the mentioned Key there was a subkey for each user that has EVER loged on to this Server. Normal load
    should be about 30 Users and i found about 700 subkey´s. To it seems that this causes the Search Service searchindexer.exe to read thru all this key´s witch i think is not the Problem ( Internet Explorer does far more reads and writes) but what happens
    with the Information.
    Maybe it has to to with the fact, that we are using User Profile Disks ?
    In the Search Service Policy i have excluded "C:","users homedrive" and the Share where the Users share theyr data, for the Search Service to exclude.
    So does anybode have experience with Seach Service on RDS Servers with Office maybe with User Profile Disks ?
    Thanks Reiner

    Hi Reiner,
    You can check the following article might helpful to resolve your case.
    Incomplete search results may occur in Outlook when a PDF iFilter is installed
    http://support.microsoft.com/kb/2925203/en-us
    Also try uninstalling office 2013 application and then reinstall by running change user /install command in elevated command prompt on RDS server prior to install software's. Post software installation you need to run
    change user /execute command on server
    http://technet.microsoft.com/en-us/library/cc742815.aspx
    Hope it helps!
    Thanks.
    Dharmesh Solanki
    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]

  • Windows Updates constantly failing and reverting after SCCM 2012 R2 pushes out updates

    Hi folks,
    I wonder could anyone help me with a strange problem I am having!
    We use SCCM 2012 R2 and I am trying to roll out updates to a Windows 2008 R2 Standard 64 bit server. 
    When I deploy the updates to the server they get to the server and install but during the reboot it says Windows Modules Installer for a while then shows the failure configuring Windows Updates, reverting changes screen.
    I’ve tried the suggestions of disabling 'Windows Management Instrumentation' and 'Windows Modules Installer' and renaming the repository folder but still no joy.
    If I use Windows Update to install the updates the updates do go on but then when I add it to the collection in SCCM to push out the patches it sees the server as if the updates aren’t installed and begins doing the installs. 
    After the patches installs using SCCM and when the server is rebooted it goes back into the loop of saying Windows Modules Installer and reverts the updates and strips out the patches again.
    I was hoping that when the Windows Updates were installed via Windows Update and once I put the server into the collection to push out the updates to the server it would have shown that the updates are already installed on the server and show that server
    as being compliant in SCCM but unfortunately that isn’t happening.
    It sights a couple of errors in the Setup event logs on the offending server: -
    For multiple patches - Package KBXXXXXXX failed to be changed to the Installed state. Status: 0x80070643
    For multiple patches - Initiating changes for package KBXXXXXXX. Current state is Invalid Resolved. Target state is Installed. Client id: WindowsUpdateAgent.
    After doing some research,
    0x80070643 refers to a .Net Framework issue so I’ve ran a .Net Repair tool but that didn’t work either so I’m running out of ideas so any help would be greatly appreciated on how I can get this sever updated using SCCM and showing as compliant.
    Thanks,
    Bonemister

    Hi Torsten,
    Thanks for your reply!
    I was afraid you were going to say that as it just doesn't make sense that when I install the update using Windows Update via the Ire-nternet and when the install and re-scan no updates are required.  It is only when I ask SCCM to check for patches
    that it sees updates are missing and installed the updates before the OS reverts when.
    Is there a way in SCCM to remove the record of what patches have been installed onto a particular server?  I tried deleted the server out of SCCM then applying the Windows Updates via the web then added the server back into SCCM and see did it pick
    up the newly installed updates on the server.
    The thing is I don't think that WindowsUpdate.log will show any failures as Windows update is showing as no more updates required.  It is just when SCCM installs that patches that the problem happens so that is what is leading me to think it is an SCCM
    problem.
    My main goal is to get the updates into the server and for it so show as complient!
    I'll check back through the even logs again.  Are they any SCCM logs that show patches failing to install and why?
    Thanks again,
    Bonemister

  • Subroutine should execute just after Commit

    Hi All,
    I am working on user exit. I am writing the subroutine in the user exit. This user exit is in SAP Standard program and this sap standard program have the commit statement. My requirment is that subroutine should execute just after the commit statement, not before.
    What can I do for that. I tried with perform on commit and in update task but both execute just before Commit. Pls help me out.
    Thanks,
    Rakesh

    Hi,
    Check the below link for documentation.
    Hope it would be of some help to you.
    http://help.sap.com/saphelp_47x200/helpdata/en/41/7af4e3a79e11d1950f0000e82de14a/content.htm
    Regards,
    Vara

  • BAM Deployment error - Microsoft.BizTalk.Bam.Management.BamManagerException: The BAM deployment failed. --- Microsoft.BizTalk.Bam.Management.BamManagerException: Encountered error while executing command on SQL Server "ServerName".

    HI,
    I am getting below error while deploying BAM activity ...Pls help me resolve this issue.
    Microsoft.BizTalk.Bam.Management.BamManagerException: The BAM deployment failed. ---> Microsoft.BizTalk.Bam.Management.BamManagerException: Encountered error while executing command on SQL Server
    "ServerName". ---> System.Data.SqlClient.SqlException: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or
    [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed.
    Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias
    to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An
    object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column
    name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing
    or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For
    SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements,
    verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column
    has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For
    other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements,
    look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) 
     at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock,
    Boolean asyncClose)   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)   at
    System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean
    sendToPipe, Int32 timeout, Boolean asyncWrite)   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()   at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteBatches(String cmdText)   at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteNonQuery(String
    cmdText, CommandType cmdType, Boolean inTransaction, Transaction transaction)   --- End of inner exception stack trace ---   at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteNonQuery(String cmdText, CommandType cmdType, Boolean inTransaction,
    Transaction transaction)   at Microsoft.BizTalk.Bam.Management.ViewModule.Create(XmlDocument defXmlDoc)   at Microsoft.BizTalk.Bam.Management.WorkerModule.DispatchOperation(OperationType operation, XmlDocument defXmlDoc)   at
    Microsoft.BizTalk.Bam.Management.BamManager.ProcessOneBamArtifactType(BamArtifactType bamArtifact, OperationType operation)   at Microsoft.BizTalk.Bam.Management.BamManager.ManageInfrastructure(OperationType operation)   at Microsoft.BizTalk.Bam.Management.BamManager.Deploy() 
     --- End of inner exception stack trace ---   at Microsoft.BizTalk.Bam.Management.BamManager.Deploy()   at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.HandleDeployAll()   at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.DispatchCommand() 
     at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.Run()   at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.Main(String[] args)

    Your View Name, OLAP Cube Name and certain other restrictions listed @http://msdn.microsoft.com/en-us/library/aa561577.aspx
    Please review your BAM Definitons.
    Regards.

  • Windows 8 deployment using Zenworks imaging services

    Hi,
    I would like to find some guidelines or best practices stuff in order to help me with the deployment of Windows 8.1
    For our current method with Windows 7, we used SYSPREP with offline drivers for multiples machines in a local folder ex. C:\Drivers.
    Now it seems that it won't work anymore with Windows 8, and when we ask for help in the Microsoft forums we are pushed to products like MDT,WDS and SCCM.
    Does anyone here had a successful Windows 8 deployment ?
    Thank you in advance for your input

    Originally Posted by anto28
    Yes i have
    I asked this question a multiple forums but i have not received any satisfying answer yet...
    Can you elaborate with the DPinst way ?
    At what point do you use this command to inject drivers ? In the audit mode ?
    I think DPInst require the hardware to be present in order to work, no ?
    What if you want to install drivers for 7-10 different machine type in your image ?
    Thank you Thomas.
    Simply put, you call dpinst on first login after the image is deployed on the workstation by adding the following to sysprep unattend xml:
    <FirstLogonCommands>
    <SynchronousCommand wcm:action="add">
    <CommandLine>c:\drivers\dpinst.exe /path C:\drivers\pnp</CommandLine>
    <Order>1</Order>
    <RequiresUserInput>false</RequiresUserInput>
    </SynchronousCommand>
    and dpinst xml should look something like this:
    <?xml version="1.0" ?>
    <dpinst>
    <search>
    <subDirectory>*</subDirectory>
    </search>
    <legacyMode/>
    <quietInstall/>
    <suppressWizard/>
    <scanHardware/>
    </dpinst>
    You could add all the drivers to the base image or then use addon images for specific workstations models that places the workstation specific driver into: C:\drivers\pnp.
    Thomas

  • Unable to execute update commands after improper shutdown

    Hi!
    It sounds a little strange.
    I am unable to execute update commands from my application. My machine was shutdown improperly. Then I loaded the datastores again. I was able to execute select commands but unable to execute update commands. It was working fine before shutdown.
    Regards
    /Ahmad

    Hi Chris!
    SQLExecute method of ODBC is returning -1.
    I have checked the syntax of the query its also correct. I am also very confused on it why is this happening. If I execute the update command from ttisql it works ok.
    The code is the same that we discussed in our previous conversation.
    The steps I did after improper shutdown:
    1. Started TimeTen daemon >ttdaemonadmin -start
    2. Loaded the Data store >ttAdmin -ramLoad spiderM
    3. Executed the code
    The output of ttstatus is as follows:
    TimesTen status report as of Fri Jun 29 21:45:41 2007
    Daemon pid 8273 port 17001 instance tt70
    TimesTen server pid 8284 started on port 17003
    TimesTen webserver pid 8280 started on port 17005
    Data store /tmp/spiderM
    There are 6 connections to the data store
    Data store is in shared mode
    Shared Memory KEY 0x08004f3c ID 557070
    Type PID Context Connection Name ConnID
    Subdaemon 8278 0x0000000000570520 Worker 2042
    Subdaemon 8278 0x00000000005dc4d0 Flusher 2043
    Subdaemon 8278 0x000000000060d5d0 Checkpoint 2044
    Subdaemon 8278 0x000000000063e5a0 Aging 2045
    Subdaemon 8278 0x000000000066f570 HistGC 2046
    Subdaemon 8278 0x00000000006a0430 Monitor 2047
    RAM residence policy: Manual
    Data store is manually loaded into RAM
    Replication policy : Manual
    Cache agent policy : Manual
    Data store /usr/users/spider/TimesTen/tt70/info/TT_tt70
    There are no connections to the data store
    Replication policy : Manual
    Cache agent policy : Manual
    Access control enabled.
    End of report
    Regards
    /Ahmad

  • Windows 8 and IE 10 crashed after printing from Report Manager SQL server 2008 / 2008 R2

    We have a problem with Windows 8 in combination with IE 10 and printing reports.
    When we print a report from the Report Manager 'http://<servername>/reports' the browser crashed after a print.
    Sometimes before printing and somthimes after printing or when you close the browser.
    Al other operating systems like XP, Vista, Windows 7 with different IE versions have no problem.
    I tried the report manager from SQL Server 2008 and SQL Server 2008 R2.
    The same error occured when printing from our Internet application and the reportviewer.
    (ASP application written in Visual Studio 2010 and reportviewer version 10.)
    The event log shows two different messages.
    Faulting application name: IEXPLORE.EXE, version: 10.0.9200.16453, time stamp: 0x509b0dfb
    Faulting module name: ntdll.dll, version: 6.2.9200.16420, time stamp: 0x505aaa82
    Exception code: 0xc0000005
    Fault offset: 0x00061252
    Faulting process id: 0x780
    Faulting application start time: 0x01ce03a294f7d1d5
    Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
    Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
    Report Id: d4a72486-6f96-11e2-be6e-10604b6a74ed
    Faulting package full name:
    Faulting package-relative application ID:
    Faulting application name: IEXPLORE.EXE, version: 10.0.9200.16384, time stamp: 0x50107ee0
    Faulting module name: rsclientprint.dll, version: 2009.100.1600.1, time stamp: 0x4bb67a74
    Exception code: 0xc0000005
    Fault offset: 0x00017e7a
    Faulting process id: 0x9c8
    Faulting application start time: 0x01ce02f35c70ab85
    Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
    Faulting module path: C:\Windows\Downloaded Program Files\rsclientprint.dll
    Report Id: a13fccc6-6ee6-11e2-be67-10604b6a74ed
    Faulting package full name:
    Faulting package-relative application ID:
    Is there a fix for this problem?

    Dear Mike Yin,
    Thank you for your response. Your answer was the
    reason for finding the real problem.
    In december 2010 a SQL Server 2008 fix was the cause. I don't remember exactly the problem, but we changed the RSCLIENTPrint-x86.cab file. But instead to use the version of SQL Server 2008 we used the version of SQL Server 2008
    R2 (10.50.1600.1). This worked until
    Windows 8 (Internet Explorer crashed when printing).
    We fixed this problem by using the RSClientPrint-x86.cab file from SQL server 2008 (10.0.5500.0).
    But we now get the known problem that the
    activeX always must be installed again. 
    The reason for this is that the version of
    the SQL Server (10.0.5512.0) 
    and the rsclientprint.dll (10.0.5500.0) is different. SQL Server is newer (caused
    by a security patch (KB2716436)).
    Do you know when this problem will be resolved
    by Microsoft?
    Work arrounds
    I've also tried to install the RSClientprint.dll
    every time automatically (without user interaction).
    But this will be delayed the printing for more
    than 4 seconds. This
    is very annoying.
    Another workaround is to generate a PDF and print the PDF. But this is also
    a lot slower.
    Uninstall the security patch. but I don't know the security risk.

  • Vista: use the windows program manager to execute operating system commands

    attempting to run forms 6 on vista... the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.
    in windows vista i get a message box indicating "use the windows program manager to execute operating system commands".
    is this windwos vista message? would this have to do with permissions?
    any insight most appreciated and thanks in advance.

    I don't know about the HOST-problem, but..
    the forms app attempts a call sqlplus using the host builtin to populate some tables before calling the report.What about putting the logic from the SQL*Plus-scripts into a database-procedure and call that instead. I think,, with the current approach you will get problems at least when you have to migrate to Web (e.g. Forms 10g).

  • Could not execute command "getState" for server server01 using nodemanager

    Hi,
    I have built a weblogic 9.1 env with 2 managed servers running on different boxes from the admin server.
    I am having problems in starting the managed servers using the nodemanager. I get the following error message in the Admin server log:
    <Error> <NodeManager> <BEA-300034> <Could not execute command "getState" for server "******" using the node manager. Reason: I/O error while reading domain directory: java.io.FileNotFoundException: Domain directory '/opt/bea/weblogic91/common/nodemanager' invalid (domain salt file not found).>
    I get the following message on the admin console:
    For server ******, the Node Manager associated with machine ******-machine is not reachable.
    All of the servers selected are currently in a state which is incompatible with this operation or are not associated with a running Node Manager. No action will be performed.
    I can start the managed server using the "startMangedWeblogic.sh" without any issues.
    Any help on this would be greatly appreciated.
    Thanks

    one more thing to add:
    I get the following error in the Managed server log:
    <I/O error while reading domain directory: java.io.FileNotFoundException: Domain directory '/opt/bea/weblogic91/common/nodemanager' invalid (domain salt file not found)>
    java.io.FileNotFoundException: Domain directory '/opt/bea/weblogic91/common/nodemanager' invalid (domain salt file not found)
    at weblogic.nodemanager.server.DomainManager.initialize(DomainManager.java:74)
    at weblogic.nodemanager.server.DomainManager.<init>(DomainManager.java:46)
    at weblogic.nodemanager.server.NMServer.getDomainManager(NMServer.java:239)
    at weblogic.nodemanager.server.Handler.handleDomain(Handler.java:170)
    at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:104)
    at weblogic.nodemanager.server.Handler.run(Handler.java:64)
    at java.lang.Thread.run(Thread.java:595)

  • Executing command in new powershell window

    Hello guys, I'd like explore directions with gci, but the thing is that istead of using -recurse I'd like to open every single direction in new powershell window. I've made something like this:
    function Get-ScriptDirectory
        $Invocation = (Get-Variable MyInvocation -Scope 1).Value
        Split-Path $Invocation.MyCommand.Path
    $path = Get-ScriptDirectory
    $paths = Get-ChildItem $path -Recurse | ?{ $_.PSIsContainer }
    foreach ($element in $paths) 
        start-process powershell
        $new= $path, $element -join "\"  
        gci $new
    But I don't know to make Powershelle execute command in new window. Start-process powershell only opens new window, but it doesn't import bolded commands. Can I get any suggestions?

    Hi Shadston,
    To add cmdlet in "-command", please refer to the script below:
    Get-ChildItem (Split-Path $MyInvocation.MyCommand.Path) -Recurse -Directory |ForEach-Object{
    start-process -FilePath powershell -ArgumentList @('-NoExit',"& {GCI '$($_.FullName)'; Write-Host 'Hello' }")
    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]

Maybe you are looking for