Trap command in powershell

hello, 
i have script that want users when script run can not terminate it with ctrl+c like trap command in linux also i want ignore signal interrupt any way and user when want try use ctrl+c prompt to enter password 
$password ="soheil"
$pass = Read-Host -AsSecureString -Prompt "Enter preshared key:" 
if ( $password -ne $pass ){
logoff
else 
powershell}
please advise me to complete my script
regards 

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.

Similar Messages

  • How to trap Command Line errors

    Sigh.  I have searched for 3 hours to the answer for my question.  I'm new to scripting, so perhaps this is the problem in my not finding a solution.
    In a nutshell, I simply want to gracefully trap command line usage of a script.  I want to have my script accept a parameter (ie. a value) and a switch.
    Example:  <script> -path <path> -set
    The problem is that i cannot trap incorrect usage.  I would prefer <path> to be position one, and -switch to be position 2 of the parameters passed to the script.  I have not tried this "outside" of PS v2.0 ISE (ie. Powershell.exe). 
    Of course, I would love it to work in both environments.
    I KNOW that the ISE will prompt for missing mandatory parameters.  Great.  But incorrectly specified parameters causes Powershell ISE to "bomb-out".  That is, displaying error messages to an uninformed user whom views it as unintelligible.
    Example of incorrect usage:  <script> -pat <path> -set
    Again, I would LOVE to trap this, and display correct USAGE to the screen.  Unfortunately, this produces a Powershell error message which has proved unintelligible to "simple" users.
    Perhaps I must accept that this is not possible in Powershell v2.0.  I simply want to program my script to CATCH this error and take the desired action.
    HELP!!!  To the knowledgeable and generous Scripting Professionals.
    If the directions say go straight, but I turn left, then right: Will I still get there?

    Okay, I stripped down the script:
    <#
    ===============================================================================
    PQSC PowerShell Source File
    NAME   :
    AUTHOR : PQSC.Programmer
    DATE   :
    COMMENT: Expects -->U:\Users\Public\Public Programs\PQSC\Scripts<-- appended to Execution Path
             CommandLine to Test=powershell -debug -command "U:\Users\PQSC.Programmer\Documents\WindowsPowerShell\Get-FilesWithArchiveBitSet.ps1" -x
    ===============================================================================
    #>
    <# ---------------------------------------------
    # Param1 is mandatory, Param2 is optional.
    # Param1 should be:  -path <path>
    # Param2 should be:  -Set
    #>
    [CmdletBinding()]
    Param(
        [parameter(Mandatory=$true,Position=1)]
        [AllowNull()]
        [AllowEmptyString()]
        [String]
        $Path,
        [switch]
        $Set_Archive
    PRODUCES THIS ERROR in PowerShell v2.0 ISE when invoke with:
    powershell -debug -command "U:\Users\PQSC.Programmer\Documents\WindowsPowerShell\Get-FilesWithArchiveBitSet.ps1" -x
    powershell.exe : Missing expression after unary operator '-'.
    At line:1 char:11
    + powershell <<<<  -debug -command "U:\Users\PQSC.Programmer\Documents\WindowsPowerShell\Get-untitled2.ps1" -x
        + CategoryInfo          : NotSpecified: (Missing express...y operator '-'.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    At line:1 char:2
    + - <<<< debug -command U:\Users\PQSC.Programmer\Documents\WindowsPowerShell\Ge
    t-untitled2.ps1 -x
        + CategoryInfo          : ParserError: (-:String) [], ParentContainsErrorR
       ecordException
        + FullyQualifiedErrorId : MissingExpressionAfterOperator
    If the directions say go straight, but I turn left, then right: Will I still get there?

  • Would like help with trap command in Terminal

    I'm learning about the trap command from my bash book. I tried out the little script they gave:
    Code: 
    trap "echo 'You hit control-C!' " INTwhile true; do     sleep 60done
    But when I type control-c, the script just stops and the message is not displayed. I checked trap -l and saw that control-c is intr, but the same thing happened whet I tried that. Can anyone tell me what I'm missing?
    I'm using terminal (BSD) in OS X Snow Leopard

    I'm assuming that you are typing these commands in the terminal window and not initiating them thru a shell script. I'd like to suggest that you avoid infinite loops. Since you are bound to orphan processes. I'm going the use the external sleep command in my examples because it affords us some time to type CONTROL-C.
    [bash-4.2.8]~ $ trap "echo '......You hit control-C'" INT; sleep 15
    ^C  
    [bash-4.2.8]~ $
    [bash-4.2.8]~ $ ^C......You hit control-C
    The trap is set but Bash does not intercept the trap because sleep is running in the foreground. The interrupt signal is sent to the command sleep.
    Let's try running sleep in the background ->
    [bash-4.2.8]~ $ trap 2 #Set SIGINT to it's default
    [bash-4.2.8]~ $ trap "echo '......You hit control-C'" INT; sleep 15&
    [1] 368
    [bash-4.2.8]~ $ ^C......You hit control-C
    [bash-4.2.8]~ $ ^C......You hit control-C
    [1]+  Done                    sleep 15
    [bash-4.2.8]~ $ ^C......You hit control-C
    It works! Well, almost. You can't send the interrupt signal to a background process. In order for Bash to intercept the trap it must stay in the foreground. This happens when you initiate a sub-shell via a shell script or by rapping a command in paretheses ( ) ->
    [bash-4.2.8]~ $ trap 2  #Set SIGINT to it's default
    [bash-4.2.8]~ $ (trap "echo '......You hit control-C'" INT; sleep 15) ^C......You hit control-C
    [bash-4.2.8]~ $
    [bash-4.2.8]~ $ ^C
    The trap works and the interrupt signal was sent to sleep. Notice, the trap is only set in the sub-shell.
    Bash behaves differently when you use the built-in commands since you are working within the shell. I'll use an example similar to one of yours, except that you can break out of the loop by typing the number 10 or higher.
    [bash-4.2.8]~ $ trap "echo '.......You hit control-C'" INT ; x=0; while (( $x < 10 )); do echo "Enter a number"; read x; done
    Enter a number
    3
    Enter a number
    ^C.......You hit control-C
    3
    Enter a number
    10
    [bash-4.2.8]~ $
    [bash-4.2.8]~ $ ^C......You hit control-C
    [bash-4.2.8]~ $ trap 2  #Set SIGINT to it's default
    As you can see the trap works. I'm going to let you sort out what happens after I typed  CONTROL -C in the last example.....:-)  Hope this helps.
    Message was edited by: Mark Jalbert

  • Why does the Illustrator "trap" command trap the same spot colors in opposite ways?

    I can not understand how Illustrator decides which way to expand something when using the "trap" command. According to their tutorial it expands the lighter-colored artwork over the darker artwork, unless you choose to reverse traps. But in practise, where two objects of the same color meet, it will frequenrly trap them in one direction in one place and the opposite direction in the other.
    Here's an example with especially large traps:
    The two yellow items are defined as the same spot color and are a single compound path. There is just the one simple shape of spot red and one simple shape of spot pink.
    On the left yellow object, it expands yellow over pink. On the right, it expands pink over yellow. On the left yellow object, it expands red over yellow. On the right, it expands yellow over red.
    There is no possible print order of these three spot colors that would result in the correct object shapes being printed the way this is trapped. Is this just a bug? Can anyone explain this result, or especially how to make it work in a useable way?
    All objects are spot colors that are cut out from each other so there were no overlaps.

    Here's what it looks like with overprint preview:
    It still looks wrong.
    This view is glossing over how bad it would really look with screen printing, because the inks are much higher opacity than they're previewing here. I suppose that's what you're getting at, that the trapping may be bad for screen printing, but if you're assuming offset press inks that have next to no opacity and will mix together on press, that it doesn't matter which way you trap. Overprint preview makes yellow overprinting pink look the same as pink overprinting yellow. With spot colors in screen printing, that is no where near the case.
    But even consdiering that, this trapping is wrong, the final shapes of the objects are changed by the trapping. And the trapping does not appear to follow Adobe's own description of the logic used, or any kind of consistency. Why would it expand yellow into pink in some places and pink into yellow in others?
    I've heard the trapping in Indesign is much better, some screen printers open in Indesign to add trapping... maybe I'll look at that.

  • 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.

  • Getting error when executing mysql command in powershell.

    When I run this it gives me an error and I'm not sure if I'm doing it right. Can someone look at my code please and thank you.
    It has a problem with the commandtext and is giving me this error:
    Exception calling "ExecuteNonQuery" with "0" argument(s): "You have an error in your SQL
    syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF @@ROWCOUNT=0 INSERT INTO signups (email,date,offer) VALUES ('morenonancy50@ya' at line 1" 
    If i take this code out of the commandtext it works, but it doesn't update the tables, it just ads new ones.
    UPDATE signups set offer='$($fileContents[$line.ReadCount+3])' WHERE email='$line' IF @@ROWCOUNT=0
    $user = 'root'
    $pass = ''
    $database = 'table01'
    $MySQLHost = 'localhost'
    $dbconnect = New-Object MySql.Data.MySqlClient.MySqlConnection
    $dbconnect.ConnectionString = $connStr = "server=" + $MySQLHost + ";port=3306;uid=" + $user + ";pwd=" + $pass + ";database="+$database+";Pooling=FALSE"
    $dbconnect.Open()
    $datefin = get-date $($fileContents[$line.ReadCount+0]) -format 'yyyy-MM-dd'
    $sql = New-Object MySql.Data.MySqlClient.MySqlCommand
    $sql.Connection = $dbconnect
    $sql.CommandText = "UPDATE signups set offer='$($fileContents[$line.ReadCount+3])' WHERE email='$line' IF @@ROWCOUNT=0 INSERT INTO signups (email,date,offer) VALUES ('"+$line+"','"+$datefin+"','"+$($fileContents[$line.ReadCount+3])+"');"
    $sql.ExecuteNonQuery()
    $dbconnect.Close()

    Hi Joey,
    Based on my research, you have mutiple statements in sql cmd: change the "offer" value based on "email" and add a new row to the sql table.
    To work with mutiple SQL statements, you can try to use the cmdlet
    "invoke-sqlcmd" instead, and save the sql command text below as .sql file, and check if there is any error:
    UPDATE signups set offer='$($fileContents[$line.ReadCount+3])' WHERE email='$line'
    IF @@ROWCOUNT=0 INSERT INTO signups (email,date,offer) VALUES ('"+$line+"','"+$datefin+"','"+$($fileContents[$line.ReadCount+3])+"')
    Windows Powershell script running multiple SQL statements
    Best Regards,
    Anna

  • Issue with Pasting to Command Line/PowerShell

    Hi,
    We are unable to paste text from an application other than Command Prompt (CP) or Windows PowerShell (PS) to CP or PS.
    The issue is only occurring on one of several Windows Server 2008 VMs.
    The server has been fully patched and restarted since the issue first started to occur.
    Copying and pasting text inside CP/PS and between other CP/PS windows works.
    Copying and pasting text from CP/PS to other applications works.
    UAC has never been turned on.
    We attempted to troubleshoot via different Administrative and non-Administrative users.
    We tried a clean boot - antivirus is not causing the issue.
    Obviously performing a system recovery is an option.  We can copy and paste text to PS ISE from applications, which is an acceptable solution for PS users.  However, it is still unacceptable for CP users.
    Thanks,
    NuxCase

    cguan,
    Entering cmd /k < clip results in the following output: "The system cannot find the file specified."
    I recognize that clip.exe is in the C:/Windows/System32 folder.  I opened this directory, tried the command, and received the same result.  Entering this as cmd /k < clip.exe provides an interesting response.  I reproduced the output on
    other servers for each instance described above while only copying "Hello world" in Notepad.  The following is the interesting response from cmd /k < clip.exe:
    C:\Windows\System32>cmd /k < clip.exe
    C:\Windows\System32>More? More? More? More?
    'MZÉ$' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>
    C:\Windows\System32><!-- Copyright (c) Microsoft Corporation -->
    C:\Windows\System32><assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestV
    ersion="1.0">
    C:\Windows\System32><assemblyIdentity
    C:\Windows\System32>    version="5.1.0.0"
    'version' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>    processorArchitecture="amd64"
    'processorArchitecture' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>    name="Microsoft.Windows.Filesystem.Clip"
    'name' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>    type="win32"
    The system cannot find the file specified.
    C:\Windows\System32>/>
    C:\Windows\System32><description>Clip - copies the data into clipboard</descript
    ion>
    C:\Windows\System32>
    C:\Windows\System32><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    C:\Windows\System32>    <security>
    C:\Windows\System32>        <requestedPrivileges>
    C:\Windows\System32>            <requestedExecutionLevel
    C:\Windows\System32>                level="asInvoker"
    'level' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>                uiAccess="false"
    'uiAccess' is not recognized as an internal or external command,
    operable program or batch file.
    C:\Windows\System32>            />
    C:\Windows\System32>        </requestedPrivileges>
    C:\Windows\System32>    </security>
    C:\Windows\System32></trustInfo>
    C:\Windows\System32></assembly>
    C:\Windows\System32>
    C:\Windows\System32>More?

  • Importing PST file using Import-Mailbox Command Crashes Powershell

    I am attempting to import a .pst file into a mailbox via the Import-Mailbox powershell command. The command starts and imports the deleted items and creates the folder structure in the Inbox then crashes powershell. I am running Outlook 2007 SP2 on a Windows 2003 Std SP2 server w/Exchange 2007 SP1 Update Rollup 8 management tools. I have tried everything i can think of. This happens on multiple machines with similar packages installed. No anti-virus software is installed. It happens on both pst files i am testing with and no errors are logged in the event logs either on the exchange mailbox server or the server i am using to do the import.

    Have you tried to do this from the actual Exchange 2007 server?  I assume you are trying to import the pst to an Exchagne 2007 email account to Exchange 2007 correct?
    Have you tried to perform the import on a Windows XP machine using the 32bit EMC/EMS rather then using Windows 2003 server? 
    I honestly recall in the back of my head a problem with Exchange 2007 and Outlook CDOs or something like that.  I could be wrong but I remember something from a year ago.....
    Seriously though, try it from a Windows XP machine running the Exchange Managerment Tools and see what happens rather then a W2K3 Server.
    SF - MCITP:EMA, MCTS
    Yea I double check the link i posted as well I never tried from a 2003 server either, I've always done it from an XP machine, but again we know its works because you got it to work with a newly export PST, so I think its more to do with the PST file itself, hopefully you dont have a bunch of them, if so let the users re-import them =)

  • How to use Get-WebHandler,Get-Website command in Powershell 2.0 of 64 bit system ?

    Hi,
    I am trying to use  Get-WebHandler , Get-Website  in Powershell 2.0 version .It is throwing error as below
    "  Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to
    the following error: 80040154  "
    It is working fine in powershell 4.0 version but not working  in powershell 2.0 version.Can anyone suggest solution to this.
    Some IIS commands which are working fine in Powershell 4.0 , are throwing above error in Powershell 2.0 version . Please suggest me the best solution to fix this issue

    this is a duplicate post. I suspected the same
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/87655dab-84ea-4e1d-8b43-b5c193f8702a/some-powershell-40-version-iis-commands-not-working-in-powershell-20-?forum=winserverpowershell#352bfa16-8c03-49fd-825c-89e3c150522b
    Indeed yeah we need to import module
    Regards Chen V [MCTS SharePoint 2010]

  • Running VBS wscript.shell command in PowerShell

    Hello all,
    I have encountered a VBS script that calls a homemade executable (which I did not write and have no documentation on) that has parameters that the executable reads. I'm trying to migrate this VBS script to PowerShell, and have run into a bit of trouble
    with the following 2 lines of VBS code (I've left the variable references in here for accuracy):
    Set WshShell=WScript.CreateObject("WScript.Shell")
    wshShell.Run("CreateTicket.exe ;3;"&string&" Account "&StringArray(0)&" has been removed from the following group(s);Resolved by AD;Resolved;"&strSubmitter&";"&strsamaccountname&"",0,True)
    In PowerShell, I can create a similar COM object, but I am having trouble executing the second line from above (I've replaced the variables from above with strings like they would be):
    $wshell = New-Object -ComObject wscript.shell -ErrorAction Stop
    $wshell.run("CreateTicket.exe ;3;Account testuser has been removed from the following group(s);Resolved by AD;Resolved;teststring;testuser",0,$true)
    I receive the error that it cannot find the file specified, so it's having trouble separating the parameters by the semicolons. Is there any hope for executing this in PowerShell?

    If you're migrating to Powershell, use Powershell, don't use Powershell to run VB commands.  Try this instead:
    $EXE = "c:\path\to\CreateTicket.exe"
    Start-Process $EXE -ArgumentList ";3;Account testuser has been removed from the following group(s);Resolved by AD;Resolved;teststring;testuser" -wait
    Edit:  Too slow!
    I hope this post has helped!

  • Initiate Application Installation from App Catalog via Command Line / PowerShell

    Hey Guys - 
    We have a single, fairly extensive OSD task sequence which covers systems for all departments.  Due to it being a single TS for all, PC Lab techs must manually install some apps after it finishes via the Application Catalog.  In past environments,
    I've used MDT's UDI Wizard to create a frontend where techs could select additional software they wanted installed during the TS and it worked great!  I'm trying to get something like that approved now, but in the meantime told the techs I'd come up with
    a temporary solution to make their job easier.
    Enter WPI (Windows Post Installer.)  Back in the days before I used SCCM OSD and relied in Acronis images (yuck), I used a the WPI tool which only ran once - at the first login - even before the desktop
    loaded.  It's highly customizable and basically shows a single window which lists any applications or scripts (in groups) which you have configured.  You place a checkmark beside each one you want to install, click the "Install" button,
    then watch it's installer frontend install each of the selected apps.  Once done, it either restarts the PC or exists to the desktop.  For each application I can add, I'm provided with a few options to
    install it.  Obviously, an installation command line string field, but also a few more like installation order, requirements, and dependencies. 
    My Question
    Each of the applications I've listed are in our Application Catalog and are advertised to All Users.  Even though I could simply point the installer string to the app's source path and use the same string that the SCCM Application uses, I've been asked
    to do something different.  Instead, I'm trying to find a command line string which when run would perform the same action as if a user had selected to install an Application from the Application Catalog.
    My thoughts are that if this is possible, it would probably be in the form of a PowerShell string - not just a basic command line one.  Since WPI has a frontend which shows the progress of each app's installation progress as well as overall progress,
    it's designed for the installation strings to install the app silently.  Therefore, I would much prefer my solution run silently as well if possible.
    So... does anyone have any idea for how I can make this happen? Thanks!
    In case it makes a difference or answers any questions, below are two screenshots showing most of the fields and options which may be used to configure how an application installs in WPI.  I couldn't include the Dependencies one since I could only
    attach two images to my post.  Also, the manual for WPI is embedded in the application's
    download (ZIP) and not a page on their site.  For the examples below, I used Google Chrome, but didn't configure anything besides the application's name:
    Application Detail Options
    Application Command Options
    Ben K.

    From what I'm reading, you are working towards MDT but it's not approved yet, so the goal is to:
    Deploy a "bundle" of applications as painlessly as possible without using UDI to make customizations quick.
    Lets talk options then.
    Option 1:  If machines types are in a unique OU or security group, create a collection for that and set these applications to mandatory install.  After initial deployment, the provisioner can drop the computer in the proper OU or group and you're
    good to go.  Downside:  collections refresh plus client check-in makes this less than instant.
    Option 2:  Orchestrator.  You can write a runbook that will approve and push apps.  You can then use the Orch console front end or a more friendly sharepoint/SM portal to push things out like a Manager would approve apps.  Downside:  if
    not already deployed, there's no way they would approve that infrastructure if they are hesitant about MDT/UDI :)
    Option 3:  PowerShell and WMI.  This should be doable ... but I've never tried it.  It looks like you're headed down the right path ... but i guess my question is:  if you can't have UDI when do get to pick the app?  Are you planning
    to write a full multi-box for them to check their apps after the fact?  In that case ... just have the appcontroller URL pop up on first login ... might be easier than reinventing the wheel.

  • Running commands with powershell - randomly need to press Enter for the command to continue

    Hi,
    I have noticed quiet a few times now that when i run some commands in a powershell window, the execution seems to hang and if i press enter the rest of the command is executed.
    It does it for such as simple thing as
    xcopy \\source \\dest
    repadmin /syncall /Adep
    The commands are executed but i need to press enter at some point (and multiple times) for the command to complete.
    Anyone have seen this kind of behavior?

    Something very similar to this came up recently, so I'll throw it out there.  Do you have "QuickEdit Mode" enabled for your PowerShell console?  If so, when you click your mouse somewhere in the window, it starts to select text to be copied or
    pasted, and your window title will change from (for example) "Windows PowerShell" to "Select Windows PowerShell".  When you press enter, you copy whatever was highlighted to the clipboard, and the console goes back to normal.

  • Executing commands in Powershell over SSH does not work

    0
    I'm trying to simulate Outlook email traffic over a testbed, so I am using a Powershell script to send the emails. The testbed is controlled by a Linux master server, which sends commands over a socket that are then executed on Windows 7 clients. The problem
    I'm having is that when I run the script from a Remote Desktop session, the script works perfectly. However, when the script is run from an SSH session or through the testbed code, the process hangs, usually upon the call to CreateItem(0).
    Here is the skeleton of the code (the remaining code just randomly generates text to fill the email body and assigns a subject):
    ClearHost
    Add-Type -assembly "Microsoft.Office.Interop.Outlook"
    $Outlook = New-Object -ComObject Outlook.Application
    $Mail = $Outlook.CreateItem(0) # Problem usually happens here
    $Mail.To = "$Address"
    $Mail.Subject = $Subject
    $Mail.Body = $Body
    $Mail.Send()
    I call the script using "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass .\sendmail.ps1 <email_address>"
    Other issues I've encountered include "There is no data file for sending or receiving data", which asked me to edit the profile. However, this error has only showed up infrequently. It usually just hangs.

    Read it again.
    Office products are NOT
    designed to run without a UI.  It is well documented.
    ¯\_(ツ)_/¯

  • Desperate to run on liner DOS commands in powershell

    I am down to 3 diffident on liners that work perfectly from the dos prompt but in Powershell I  get the below error.
    ADSchemaAnalyzer.exe : The term 'ADSchemaAnalyzer.exe' is not recognized as the name of a cmdlet, function, script file, or
    operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    The command is
    ADSchemaAnalyzer.exe /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"
    This is the full section of script
    # Schema START
    $env:COMPUTERNAME
    $baseserver = "$env:COMPUTERNAME.$DNSHostName"
    If (Test-Path "C:\Domain2LAB\INFO\PRODSchema.ldif") { #1
    # Find ADSchemaAnalyzer.exe and set location start
    (Get-ChildItem -Path c:\windows -Filter ADSchemaAnalyzer.exe -Recurse).Directory |Export-Csv $env:temp\scrappath.csv -NoTypeInformation
    $changepath = (Import-Csv $env:temp\scrappath.csv).FullName[1]
    $changepath
    Set-Location "$changepath"
    # Find ADSchemaAnalyzer.exe and set location end
    ADSchemaAnalyzer.exe /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"
    "Wait 15 seconds"
    Start-Sleep 15
    ldifde -i -f "C:\Domain2LAB\INFO\Test.ldif" -c dc=x $DistinguishedName
    } # 1
    # Schema END
    Please tell me there is a way to run a a one liner like the one above?
    Thanks
    Lishron

    I found it before I asked the question.   Duhhh
    It was a syntax error on my part.   I had one too many commas
    Thanks
    $command = @'
    cmd.exe /C ADSchemaAnalyzer.exe /targetLDIF "C:\Domain2LAB\INFO\PRODSchema.ldif" /baseServer $baseserver /outputLDIF "C:\Domain2LAB\INFO\LAB.LDIF"
    Invoke-Expression -Command:$command
    Lishron

  • Help converting WBAdmin command into powershell

    I am having a bit of trouble converting Windows Server Backup commands on a 2012 R2 server into powershell.
    The first command is to restore the catalog from a portable drive.  The batch file version is:
    wbadmin restore catalog -backupTarget:\\?\Volume{58895c2e-a4f6-4143-8be0-83c85hhhhhh}\ -machine:MyHost -quiet
    My attempt to convert this to powershell is:
    $Bt="\\?\Volume{58895c2e-a4f6-4143-8be0-83c85hhhhhh}\"
    Restore-WBCatalog -BackupTarget $Bt -Force
    But this fails with "Cannot bind parameter 'BackupTarget'"
    We then have the line:
    $version=@(Get-WBBackupSet)[-1].VersionId
    Which retrieves the versionId of the most recent backup ok.
    The last line we need to convert to powershell is:
    wbadmin start recovery -version:$version -itemtype:File -items:k:\Data1.vhdx -backupTarget:\\?\Volume{58895c2e-a4f6-4143-8be0-83c85hhhhhh}\ -machine:MyHost -recoveryTarget:k:\ -overwrite:Overwrite -quiet
    Thanks,

    Try changing this:
    $Bt="\\?\Volume{58895c2e-a4f6-4143-8be0-83c85hhhhhh}\"
    to this:
    $Bt='\\?\Volume{58895c2e-a4f6-4143-8be0-83c85hhhhhh}\'
    ¯\_(ツ)_/¯
    Tried that but still same problem.  Actual error message is:
    Restore-WBCatalog : Cannot bind parameter 'BackupTarget'. Cannot convert the
    "\\?\Volume{58895c2e-a4f6-4143-8be0-83c858hhhhhh}\" value of type "System.String" to type
    "Microsoft.Windows.ServerBackup.Commands.WBBackupTarget".
    At X:\System\Restore.ps1:2 char:33
    + Restore-WBCatalog -BackupTarget $Bt -Force
    +                                 ~~~
        + CategoryInfo          : InvalidArgument: (:) [Restore-WBCatalog], ParameterBindingException
        + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Windows.ServerBackup.Commands.Restore
       WBCatalog

Maybe you are looking for