How to make powershell script.

How to make script that copy content from notepad to other notepad and reverse the text?

If you mean a .txt file then there's three aspects to your question.
Open a file and read the text
Reverse the text
Save the text into a new file
For point one, this technet article is good:
http://technet.microsoft.com/en-us/library/ee692806.aspx
For point two you could turn the text into one or more strings, then convert those into arrays, loop through them and then re-assemble them. This article shows you most of that:
http://technet.microsoft.com/en-us/library/ee692804.aspx
And finally you need to save that text as a file, there's lots of ways but the Out-File cmdlet is the simplest.
This might also be of use:
http://www.ehow.com/how_7174023_write-basic-powershell-script.html

Similar Messages

  • How to add powershell script code in form application in C#

    Hi,
    i am creating a form application in C# and have powershell code which will create remote session on remote machine and execute few commands like set execution policy copy some share files install that files etc.
    I have to add this powershell script into form application in C#.
    Can some one please give me some example how to add the whole script which i have into C# code form application. Thanks in advance
    Thanks,

    Hi
    So the left is Run PowerShell Commands on Remote machine? Am I right ?
    Here  is a article talking about running  powershell commands on Remote Computers.
    http://www.howtogeek.com/117192/how-to-run-powershell-commands-on-remote-computers/
    About how to write in C#, please follow
    Joel Engineer's reply, using  process.Start() method  to start
    PowerShell.exe and Run PowerShell Commands to connect remote machine.
    Best regards,
    Kristin
    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.

  • How to export Powershell script information to Sharepoint?

    I'm trying to export information gather from a Powershell script to a Sharepoint list. I've got a couple of powershell scripts that gather general server information from a server ex: server uptime, disk space, service tag, etc. and it will export the information
    to a csv file. What I would like to do is out-put the same information gathered by the powershell scripts to a Sharepoint list directly if at all possible.
    Ex:
    # all this does is reads from a list and runs a script call "boottime.ps1"
    get-content "\\%Data-Path-Of-List%\computers.txt" | %Data-Path-Of-Script%\boottime.ps1 |  Export-csv %Data-Path-For-CSV\Computers.csv
    # then just exports the information from the boottime.ps1 script to a csv file
    #I also have a script that will upload the information to a sharepoint list.
    # I found that I have to run this in version 2 of powershell, so I just open a DOS prompt in Admin Priv's and type the following
    powershell.exe -version 2.0
    # Next I make sure the Sharepoint snap-in is loaded
    if ( (Get-PSSnapin -Name Microsoft.sharepoint.powershell - erroraction silentlycontinue) -eq $null)
    Add-PsSnapin Microsoft.Sharepoint.Powershell
    $spweb = get-SPweb $spserver
    $spdata =$spweb.getlist("%URL_Of_My_List%")
    # this is the same location from the orginal Powershell script previously stated.
    $ComputerInfoFile = "%Data-Path-For-CSV%\Computers.csv"
    foreach ($rows in $tblData) {
    # here is where I add the information from my csv file
    # 2 things needs to be present
    # 1st the colums have to be present in the sharepoint site before I can upload the information
    # 2nd the columns have to the headers in my csv file
    $spItem = $spData.AddItem()
    $SpItem["ServerName"] = $row."ServerName".toString()
    $SpItem["Uptime"] = $row."Uptime".toString()
    $SpItem.Update()
    # this just disconnects from Sharepoint
    $spWeb.Dispose()
    Please dismiss all the comments it just helps me understand what the code is doing, also if this is not the correct place to post this question I appologize in adavance and ask that if this is the incorrect place to post this question please provide me a
    link to a where I can post such questions.

    Sorry for the delay in posting this, but I ended up getting working. I'll post it in the hopes that my head scratching will save someone else some head scratching:
    I ended up writting 3 PS scripts and one batch job.
    1st Batch file
    powershell.exe -version 2.0 -command
    \\%Script-Location\Get-Server-Infor-4-SP.ps1
    powershell.exe -version 2.0 -command \\%Script-Location\Delete-list-Items.ps1"
    powershell -veriosn 2.0 -command
    \\%Script-Location\Populate-SP.ps1
    1st PS script that gets the info:
    get-content
    \\%Location-Of-My-File-With-List-Of-Servers%\%name-of-file%.txt |
    \\%Location-Of-My-Script-To-get-the-Information-I-want | Export-csv
    \\%location-of-my-output\%filename%.csv
    Ex: get-content C:\scripts\computers.txt | C:\scripts\boottime.ps1 | export-csv C:\scripts\computer.csv
    2nd PS script Delete-List-Items.ps1
    # http:
    #Script 1 Boottime.ps1:
    # This script permits to get UpTime from localHost or a set of remote Computer
    # usage
    # localHost
    # .\BootTime.ps1
    # set of remote computers
    # get-content .\MyserverList.txt | .\boottime.ps1
    # Optionally pipe output to Export-Csv, ConverTo-Html
    Process {
    $ServerName = $_
    if ($serverName -eq $Null) {
    $serverName= $env:COMPUTERNAME
    $timeVal = (Get-WmiObject -ComputerName $ServerName -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem").LastBootUpTime
    #$timeVal
    $DbPoint = [char]58
    $Years = $timeVal.substring(0,4)
    $Months = $timeVal.substring(4,2)
    $Days = $timeVal.substring(6,2)
    $Hours = $timeVal.substring(8,2)
    $Mins = $timeVal.substring(10,2)
    $Secondes = $timeVal.substring(12,2)
    $dayDiff = New-TimeSpan $(Get-Date –month $Months -day $Days -year $Years -hour $Hours -minute $Mins -Second $Secondes) $(Get-Date)
    $Info = "" | select ServerName, Uptime
    $Info.servername = $servername
    $d =$dayDiff.days
    $h =$dayDiff.hours
    $m =$dayDiff.Minutes
    $s = $daydiff.Seconds
    $info.Uptime = "$d Days $h Hours $m Min $s Sec"
    $Info
    #Script 2: Delete-List-Items.ps1
    # http://markimarta.com/sharepoint/delete-all-items-in-sharepoint-list-using-powershell/
    # there seems to be a problem with running this script in version 3 or later, the workaround is to run it in version 2
    # below is the cmd for doing so, just open up a DOS prompt with Admin Privileges Start-->Run-->cmd
    # type then copy and paste the following line the DOS window then you can run this script
    #powershell.exe -version 2.0
    # make sure that the Microsoft.SharePoint.PowerShell Snap-in is installed as well
    if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
    Add-PsSnapin Microsoft.SharePoint.PowerShell
    # "Enter the site URL instead http://serverurl"
    $SITEURL = "%http://serverurl%"
    $site = new-object Microsoft.SharePoint.SPSite ( $SITEURL )
    $web = $site.OpenWeb()
    "Web is : " + $web.Title
    # Enter name of the List below in the [“%List-Name%”]
    $oList = $web.Lists["%List-Name%"];
    # This echo out the name of the list its going to be deleting the records from
    "List is :" + $oList.Title + " with item count " + $oList.ItemCount
    # It’s just counting the rows/records
    $collListItems = $oList.Items;
    $count = $collListItems.Count - 1
    # Here is where it is actually deleting the records and then out put the number or the record it deleted
    for($intIndex = $count; $intIndex -gt -1; $intIndex--)
    "Deleting record: " + $intIndex
    $collListItems.Delete($intIndex);
    #Script 3: Populate-SP_Test.ps1
    # http://blogs.technet.com/b/stuffstevesays/archive/2013/07/10/3577320.aspx
    # there seems to be a problem with running this script in version 3 or later, the workaround is to run it in veriosn 2
    # below is the cmd for doing so, just open up a DOS prompt with Admin Privileges Start-->Run-->cmd
    # type then copy and paste the following line the the DOS window then you can run this script
    #powershell.exe -version 2.0
    # make sure that the Microsoft.SharePoint.PowerShell Snap-in is installed
    if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
    Add-PsSnapin Microsoft.SharePoint.PowerShell
    # Here are some more varables that can be added I was not able to get this to work
    #$SPComputerInfo="/Lists/PowershellTest/"
    # Here is where we connect and Open SharePoint List via Powershell
    $SPServer= "%http://serverurl%
    $spWeb = Get-SPWeb $SPServer
    $spData = $spWeb.GetList("%List-Name%")
    # This is the variable for the path that has the file I want to input to SharePoint List
    $InvFile="\\%location-ofList%\computers.csv"
    # This is just some error checking to make sure the file exist
    $FileExists = (Test-Path $InvFile -PathType Leaf)
    if ($FileExists) {
    "Loading $InvFile for processing..."
    $tblData = import-csv $InvFile
    } else {
    "$InvFile not found - stopping import!"
    exit
    # Loop through Applications add each one to SharePoint
    "Uploading data to SharePoint...."
    foreach ($row in $tblData) {
    #Here is where I add the information from my CSV file
    #2 things have to be present
    # 1. the columns have to be in the sharepoint site before I can import the information
    # 2. columns have to the headers in my csv file
    #"Adding entry for "+$row."Computer Information".ToString()
    $spItem = $spData.AddItem()
    $spItem["ServerName"] = $row."ServerName".ToString()
    $spItem["Uptime"] = $row."Uptime".ToString()
    #$spItem["DNSHostName"] = $row."DNSHostName".ToString()
    #$spItem["DistinguishedName"] = $row."DistinguishedName".ToString()
    $spItem.Update()
    # This is just disconnecting from SharePoint
    $spWeb.Dispose()
    Enjoy, and if anyone has a better way of doing this I'm interested in knowing, thanks again
    Thanks in Adavance

  • How to run Powershell script (function) through Windows Task Schduler ??

    Hello All,
    i have Powershell script which is created as a function. I have to give parameters to run the script. And it is working fine. Now i want to run this script through windows task scheduler but it is not working. I dont know how to call powershell function
    through task scheduler.
    From command line i run it like this:
    . c:\script\Get-ServiceStatusReport.ps1
    dir function:get-service*
    Get-ServiceStatusReport -ComputerList C:\script\server.txt -includeService "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail mail01.xxx.gov.pk
    In windows Task scheduler I am giving this: it runs but i dont receive any output :
    Program/Script:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter:
    -file ". 'Get-ServiceStatusReport.ps1 -ComputerList C:\script\server.txt -includeService  "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail  mail01.xxx.gov.pk'"
    Please HELP !!!

    Thanks for the reply:
    The script is already saved as Get-ServiceStatusReport.ps1 .
    On powershell it does not run like .\Get-ServiceStatusReport.ps1 (parameter).
    But i have to call it as function:
    Like this:
    Get-ServiceStatusReport -ComputerList C:\script\server.txt -includeService "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail mail01.xxx.gov.pk
    As you said:
    I tried to run it like this:
    Program/Script:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Parameter:
    -file "c:\script\Get-ServiceStatusReport.ps1 -ComputerList C:\script\server.txt -includeService  "Exchange","W32Time" -To [email protected] -From [email protected] -SMTPMail  mail01.xxx.gov.pk'"
    But its not working , on scheduler its giving error: (0xFFFD0000)
    Please HELP !!!
    WHOLE SCRIPT:
    function Get-ServiceStatusReport
    param(
    [String]$ComputerList,[String[]]$includeService,[String]$To,[String]$From,[string]$SMTPMail
    $script:list = $ComputerList
    $ServiceFileName= "c:\ServiceFileName.htm"
    New-Item -ItemType file $ServiceFilename -Force
    # Function to write the HTML Header to the file
    Function writeHtmlHeader
    param($fileName)
    $date = ( get-date ).ToString('yyyy/MM/dd')
    Add-Content $fileName "<html>"
    Add-Content $fileName "<head>"
    Add-Content $fileName "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
    Add-Content $fileName '<title>Service Status Report </title>'
    add-content $fileName '<STYLE TYPE="text/css">'
    add-content $fileName "<!--"
    add-content $fileName "td {"
    add-content $fileName "font-family: Tahoma;"
    add-content $fileName "font-size: 11px;"
    add-content $fileName "border-top: 1px solid #999999;"
    add-content $fileName "border-right: 1px solid #999999;"
    add-content $fileName "border-bottom: 1px solid #999999;"
    add-content $fileName "border-left: 1px solid #999999;"
    add-content $fileName "padding-top: 0px;"
    add-content $fileName "padding-right: 0px;"
    add-content $fileName "padding-bottom: 0px;"
    add-content $fileName "padding-left: 0px;"
    add-content $fileName "}"
    add-content $fileName "body {"
    add-content $fileName "margin-left: 5px;"
    add-content $fileName "margin-top: 5px;"
    add-content $fileName "margin-right: 0px;"
    add-content $fileName "margin-bottom: 10px;"
    add-content $fileName ""
    add-content $fileName "table {"
    add-content $fileName "border: thin solid #000000;"
    add-content $fileName "}"
    add-content $fileName "-->"
    add-content $fileName "</style>"
    Add-Content $fileName "</head>"
    Add-Content $fileName "<body>"
    add-content $fileName "<table width='100%'>"
    add-content $fileName "<tr bgcolor='#CCCCCC'>"
    add-content $fileName "<td colspan='4' height='25' align='center'>"
    add-content $fileName "<font face='tahoma' color='#003399' size='4'><strong>Service Stauts Report - $date</strong></font>"
    add-content $fileName "</td>"
    add-content $fileName "</tr>"
    add-content $fileName "</table>"
    # Function to write the HTML Header to the file
    Function writeTableHeader
    param($fileName)
    Add-Content $fileName "<tr bgcolor=#CCCCCC>"
    Add-Content $fileName "<td width='10%' align='center'>ServerName</td>"
    Add-Content $fileName "<td width='50%' align='center'>Service Name</td>"
    Add-Content $fileName "<td width='10%' align='center'>status</td>"
    Add-Content $fileName "</tr>"
    Function writeHtmlFooter
    param($fileName)
    Add-Content $fileName "</body>"
    Add-Content $fileName "</html>"
    Function writeDiskInfo
    param($filename,$Servername,$name,$Status)
    if( $status -eq "Stopped")
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$servername</td>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$name</td>"
    Add-Content $fileName "<td bgcolor='#FF0000' align=left ><b>$Status</td>"
    Add-Content $fileName "</tr>"
    else
    Add-Content $fileName "<tr>"
    Add-Content $fileName "<td >$servername</td>"
    Add-Content $fileName "<td >$name</td>"
    Add-Content $fileName "<td >$Status</td>"
    Add-Content $fileName "</tr>"
    writeHtmlHeader $ServiceFileName
    Add-Content $ServiceFileName "<table width='100%'><tbody>"
    Add-Content $ServiceFileName "<tr bgcolor='#CCCCCC'>"
    Add-Content $ServiceFileName "<td width='100%' align='center' colSpan=3><font face='tahoma' color='#003399' size='2'><strong> Service Details</strong></font></td>"
    Add-Content $ServiceFileName "</tr>"
    writeTableHeader $ServiceFileName
    #Change value of the following parameter as needed
    $InlcudeArray=@()
    #List of programs to exclude
    #$InlcudeArray = $inlcudeService
    Foreach($ServerName in (Get-Content $script:list))
    $service = Get-Service -ComputerName $servername
    if ($Service -ne $NULL)
    foreach ($item in $service)
    #$item.DisplayName
    Foreach($include in $includeService)
    write-host $inlcude
    if(($item.serviceName).Contains($include) -eq $TRUE)
    Write-Host $item.MachineName $item.name $item.Status
    writeDiskInfo $ServiceFileName $item.MachineName $item.name $item.Status
    Add-Content $ServiceFileName "</table>"
    writeHtmlFooter $ServiceFileName
    function Validate-IsEmail ([string]$Email)
    return $Email -match "^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"
    Function sendEmail
    param($from,$to,$subject,$smtphost,$htmlFileName)
    [string]$receipients="$to"
    $body = Get-Content $htmlFileName
    $body = New-Object System.Net.Mail.MailMessage $from, $receipients, $subject, $body
    $body.isBodyhtml = $true
    $smtpServer = $MailServer
    $smtp = new-object Net.Mail.SmtpClient($smtphost)
    $validfrom= Validate-IsEmail $from
    if($validfrom -eq $TRUE)
    $validTo= Validate-IsEmail $to
    if($validTo -eq $TRUE)
    $smtp.UseDefaultCredentials = $true;
    $smtp.Send($body)
    write-output "Email Sent!!"
    else
    write-output "Invalid entries, Try again!!"
    $date = ( get-date ).ToString('yyyy/MM/dd')
    sendEmail -from $From -to $to -subject "Service Status - $Date" -smtphost $SMTPMail -htmlfilename $ServiceFilename

  • How to make AE script folder?

    Hi, i want to ask something about script in after effect CS6. I have many script in my AE and I think its quite difficult to find the script i want. So, how to make script folder in AE or maybe group of script? So if I want to use the script i can find it easier....
    Thank you and sorry for my bad english...

    // create a new FolderItem in project, with name “comps”
    var compFolder = app.project. items.addFolder(“comps”);
    AE CS3 Scripting guide, page 78

  • How to make a script to convert RGB to CMYK as black 100%?

    Hi guy
    my customer sent me a book (144 pages) for print but all of them are RGB and Tiff, she scan them. there are on the page some texts and pictures. The text are R=30 G=30 B=30.I think if I can make a script I will do it very soon to black 100%, but unfortunately I dont know anything to make script 
    anybody can help me ?anybody can make it for me ?

    We need to know some more information.
    1. The book consists of 144 pages, and each page is in fact an RGB image in TIFF format.
        Correct?
        That means, the text is already rasterized, but with low resolution (no more than 300ppi).
        A very bad starting point, in my humble opinion. For offset printing this is not acceptable.
    2. Is the printing process offset printing or by digital printing?
    Nevertheless we may think about a conversion of these images into CMYK K-only (one plate
    per page) . 
    a) Increase contrast until R=G=B=0 for text.
    b) Convert each image into Grayscale, using a so-called Black-Ink-Profile, for instance
        Black-Ink-ISOCoated-v2-eci (can be explained later)
    c) Make empty CMYK image, here for  ISOCoated-v2-eci, and paste the Grayscale into the
        K-channel. All further handling happens as CMYK file for the process ISOCoated-v2-eci.
        Void plates CMY don't matter.
        Post #12 here:
        Re: Colour shift (from CMYK = 0 0 0 20 to Grayscale K = 22 !)
    All this can be done by an action (I hope so...).
    Much better would be a new start by InDesign with typographical text (K-only vector instead of raster)
    with images in RGB or CMYK, taking into account the intended process.
    Note: Photoshop can deliver vector text, if exported as PDF.
    Best regards --Gernot Hoffmann

  • Launchd: how to make a script run every weekday?

    I'm trying to make a script run every weekday as a LaunchAgent. Is there a way to do this like you could in cron?
    Here is the relevant portion of my LaunchAgent plist:
    <key>StartCalendarInterval</key>
    <dict>
    <key>Hour</key>
    <integer>9</integer>
    <key>Minute</key>
    <integer>0</integer>
    <key>Weekday</key>
    <integer>3</integer>
    </dict>
    I have tried changing the Weekday integer to 1-5 or 1,2,3,4,5 but neither worked. It only works with a single integer. Do I have to create 5 separate plists for each weekday?
    Any ideas?

    Thanks VK, for others who are looking to do something similar, here is the relevant part of the code to make the command run every day (since that field is missing) at 7:00pm and 7:01pm:
    <key>StartCalendarInterval</key>
    <array>
    <dict>
    <key>Hour</key>
    <integer>19</integer>
    <key>Minute</key>
    <integer>00</integer>
    </dict>
    <dict>
    <key>Hour</key>
    <integer>19</integer>
    <key>Minute</key>
    <integer>01</integer>
    </dict>
    </array>

  • How to make a script for find text object?

    Hi everyone
    I want to make a script for find and select text object and then find next, find next, and so on, but without any open dialog
    Is that possible make a script for this?
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat = "(\[\x{2022}\])|(\x{25CF})";
    app.findGrep();
    thanks
    Regard

    You already have that. A script does not 'find, select, find next' - it finds all texts as soon as you execute the 'app.findGrep' command.

  • How to make a script for a terminal command

    I need to find instructions on how to create a script to automatically run the following Terminal command;
    Sudo chmod 755 /private/var/spool/cups. It will also need to include the admin password as you will be prompted to enter it after the command line is entered. Apparently the only way to get Quark 7 to print adobe pdf's is to open a terminal window and type the command every time the machine is rebooted. This is a temporary fix and I do not want the MAC users to have to type the command.
    Thanks
    Sal

    This Script works here. Get you the error, when you save or checks the syntax?
    When you use in AppleScript the entry with administrator privileges, is sudo optional. This says only, if everyone can use the sudo command inside of the 5 minutes limit without to write the password again or not.
    The Syntax do shell script "sudo chmod 755 "private/var/spool/cups" password "***" doesn´t work, because you need the entry with administrator privileges for the execution as privileged user.

  • How to make a script for expand column width

    Hi experts,
    Is that possible to make a script for expand the column width aim to let the columns show up all the overset text?
    Regard
    John

    Hi John,
    As Uwe advised it would be wise to put a stop on any while loop in case the condition is never fulfilled which would mean the script will break.
    Without knowing what specifically you are working on you could make the below amendments to do this.
    myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();
    for (var t = 0; t < myTables.length; t++) {
        BE_resizeColumnsToFitContents(myTables[t], 200);
    function BE_resizeColumnsToFitContents(tableToEdit, tableMaxWidth) {
        for (var i = 0; i < tableToEdit.columns.length; i++) {
            while (tableToEdit.columns[i].overflows === true) {
                if (tableToEdit.width < tableMaxWidth) {
                    tableToEdit.columns[i].width += 1;
                    tableToEdit.columns[i].recompose();
                else {
                    alert("Column " + i + " contents too large for column.");
                    break;
    I won't put any extra functions in this because it might not be what you're after. To use this you just define the table width as a second argument to the function (but you could change this parameter to something else, like page, column or cell width). And, if you want to have a fail action you just put it in the 'else' part.
    Brett

  • How to make this script work

    Help me to make this script work, please!
    function(){
    app.findGrepPreferences.firstLineIndent  = "8 mm";
    app.findGrepPreferences.leftIndent  = "8 mm";
    app.changeGrepPreferences.firstLineIndent  = "8 mm";
    app.changeGrepPreferences.leftIndent  = "16 mm";
    app.selection[0].changeGrep();
    app.findGrepPreferences.leftIndent  = "16 mm";
    app.changeGrepPreferences.leftIndent  = "24 mm";
    app.selection[0].changeGrep();

    Hi,
    Its already replied, see below code:
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.firstLineIndent  = "8 mm";
    app.findGrepPreferences.leftIndent  = "8 mm";
    app.changeGrepPreferences.firstLineIndent  = "8 mm";
    app.changeGrepPreferences.leftIndent  = "16 mm";
    app.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    First run the above code, again you want to change leftIndent from '16 mm' to '24 mm' run below code:
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.leftIndent  = "16 mm";
    app.changeGrepPreferences.leftIndent  = "24 mm";
    app.changeGrep();
    app.findGrepPreferences = app.changeGrepPreferences = null;
    by
    hasvi

  • How to make Apple Script do a terminal command

    Hey,
    I am wondering how can I make an AppleScript do the following command :
    "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
    Please mention step by step since I'm new to AppleScript
    Best Regards,
    Nadav.

    To run a terminal command it is usually sufficient to use do shell script. So for your command it would be
    do shell script "networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4"
    note if the command requires administrator privileges you would need to do
    do shell script "command"  with administrator privileges
    will prompt for the password when the script is run.
    do shell script "command" user name "me" password "mypassword" with administrator privileges
    will store the password and username in the script. More convenient but much less secure.
    See do shell script in AppleScript

  • How to Excute powershell scripts from C#

    hi all,
    I am using Exchange server 2013, i am getting Users list in powershell using the command
    Get-Mailbox -ResultSize Unlimited | Select Name,Alias,RecipientTypeDetails | Export-Csv c:\Users.csv
    i need to get through this C# code.
    I am trying with following code , but i am getting error
    Runspace runspace = RunspaceFactory.CreateRunspace();
    runspace.Open();
    PowerShell powershell = PowerShell.Create();
    PSCommand command = new PSCommand();
    powershell.AddCommand("Get-Mailbox");
    powershell.AddParameter("ResultSize", "Unlimited");
    powershell.Runspace = runspace;
    Collection<PSObject> results = powershell.Invoke();
    I am running code in directly in server, so no need to setup Remote powershell session.
    by running above code i am getting error below
    The term 'Get-Mailbox' 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

    Hi DareDevil57,
    Thanks for reply.
    i Created new user[ExchangeAdmin] by giving full Access permissions of all users. but still i am not getting list of MailBoxes  in Exchange server.
    SecureString secureString = new SecureString();
    string myPassword = "EIS2014!@#"; string username = "[email protected]";
    foreach (char c in myPassword)
    secureString.AppendChar(c);
    PSCredential ExchangeCredentials = new PSCredential(username, secureString);
    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("http://ExchangeServer.admin.com/powershell ), "http://schemas.microsoft.com/powershell/Microsoft.Exchange , ExchangeCredentials);
    Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
    runspace.Open();
    string newCommand = "Get-Mailbox -ResultSize Unlimited";
    Pipeline cmd = runspace.CreatePipeline(newCommand);
    Collection<PSObject> results = cmd.Invoke();
    runspace.Close();
    how can i get list of all Mailboxes in C# code ?

  • Import-csv how to make powershell ignore a line in a csv file if a column contains a certain value

    Basically I got a very basic script that uses a csv file to input values needed to remove people from a distro list. That part is working fine. I'd like to add to it's functionality so it can look at values in a certain column, and if any of those certain
    values are present, I want powershell to skip that line and not process it. For instance I have a column in the csv called Group. If I have a listing under Group that says ABC I want the script to skip that line and not try to process it. What could I insert
    into the script to acheive this?

    You're welcome. You can add to the if test with -and:
    Import-Csv .\groups.csv | ForEach {
    If ($_.Group -ne 'ABC' -and $_.Group -ne 'DEF') {
    Write-Output "Group is $($_.Group)"
    Write-Output "Name is $($_.Name)"
    Output:
    Group is GHI
    Name is Show Me
    groups.csv:
    Group,Name
    ABC,Skip Me
    DEF,Skip Me Too
    GHI, Show Me
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • How to make a script treat only tables of one layer?

    Hi guys
    Could anyone  point the way to performing the below code only on one layer in  Indesign CS2?
    I also need to treat tables on "layer1" only.
    with(app.activeDocument){
    for(  storyIndex = 0; storyIndex < stories.length; storyIndex++)
                var myStory = stories.item( storyIndex );
                for (tableIndex = 0; tableIndex <  myStory.tables.length; tableIndex++)
                    //do things here
    This works on the  whole document but how can I ask Indesign to treat only tables in  "layer1". The layer object does not contain the story object, so I cant  adjust the "with" statement above.
    Basically what I need to do is untag all XMLelements within a table of layer but i have given the obove code for simplicity.
    Can anyone guide me on this?
    Thanks
    Nadia

    CS2, huh? If you have not already, you should budget for an upgrade to CS5.5 (or better yet, CS5 right now and get the free CS5.5 upgrade,so you have both, assuming that offer is still outstanding).
    Generally using with is discouraged. It makes it hard to tell what's really going on in your program and is considered bad style [at least by me]. Better to use either a temporary variable or app.activeDocument.stories explicitly.
    Stories do not themselves have a concept of a layer, because they are composed of textFrames and those could be on different layers.
    But let's assume that you care about the layer of the first textFrame in each story.
    Then:
    var
      stories = app.activeDocument.stories,
      storyIndex, myStory,
      tableIndex;
    for (storyIndex = 0; storyIndex < stories.length; storyIndex++) {
      myStory = stories[storyIndex];
      if (myStory.textFrames[0].itemLayer.name === 'layer1') {
        for (tableIndex = 0;
             tableIndex <  myStory.tables.length;
             tableIndex++
          //do things here
    (I also use stories[15] instead of stories.item(15) and declare all vars at the top.)

Maybe you are looking for

  • Verizon Reception and Customer Service On Extreme Decline

    My husband has been a loyal Verizon customer for almost a decade and I was on Tmobile several years back.  He told me that Verizon was great and it was true...3 years ago, and so I decided to cancel my Tmobile service and join Verizon....even though

  • How to install content server

    Hi all, I am new to DMS.How to install content server? and What is the difference between Content server and Kpro server? Thanks and Regards, Vairavan

  • ORDImageSignature Invalid data type in Oracle 8i

    hi there, i have just started working on Intermedia, i am using Oracle 8i. i have configured the intermedia and executed the ordwebutl.sql file. all othe media data types are working perfectly like, ORDAudio, ORDImage,ORDVideo, but the ORDIMageSIgnat

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen.. is there a way for us to write a SQL query which specifies to output the query results to a text file. Pls let me know how to do it Thanking u in advance regards M

  • Nokia E72 Panel - Where can I buy it please?

    I need a complete Nokia E72 Panel including the LCD. Where can I buy it please? Been searching everywhere but have not got it Moderator's note: The post was moved to the appropriate board.