Concatenate variable with string in sharepoint power shell

Hello ,
  I have written the following script :
         $SiteURL ="http://mysite.com"
         <a href= $SiteURL + "/Lists/AllItems.aspx">Data</a>
   The concatenation in href not correct . how can I do the concatenation ?
  Thanks
ASk

Hello ,
  Thanks for ur reply . I have test your sample , but it is not working correctly . The generated url was "http://mysite/sites/tt/pages/Lists/FieldsMappingList"
  The script that i used :
    $siteUrl = "http://mysite/sites/tt";
$pageURL = "Pages/Admin.aspx"
$site = New-Object Microsoft.SharePoint.SPSite($SiteUrl)
$psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$web=$site.RootWeb
$file = $web.GetFile($pageURL)
if ($file.Level -ne "CheckOut")
  $file.CheckOut()
$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
 foreach($webPart in $wpm.WebParts)
           if($webPart.GetType().Name -eq "ContentEditorWebPart")
             $cewp=[MicroSoft.SharePoint.WebPartPages.ContentEditorWebPart]$webPart
             $xmlDoc=New-Object System.Xml.XmlDocument
             $xmlElement=$xmlDoc.CreateElement("MyElement")
             $xmlElement.InnerText='<div class="clear">
                                     <table class="admin"><tbody>
                                      <tr>
                                       <td>
                                        <a href= $($SiteURL + "/Lists/FieldsMappingList")>
                                         <img src="/_layouts/IMAGES/VGSP.VIS.TicketTale/common/remedy.png" alt=""/>
                                         <h1>Remedy Fields Mapping</h1>
                                         <span>a list containing fields mapping between remedy and ticket tale </span>
                                         </a>
                                       </td>
                                     </tr>
                                   </tbody></table>
                                  </div>'   
             $cewp.Content=$xmlElement    
             $wpm.SaveChanges($cewp)            
$file.CheckIn("CheckIn")
$file.Publish("Published")
ASk

Similar Messages

  • Setting VarChar Variable with String Parameter in Crystal Report Add Command

    Setting a VarChar Variable with a String Parameter in a Crystal Report 2008 SP6.3 Add Command is causing an error with a SQL State of 42000.  The Error Code depends on which value I select for the parameter.  I created the @DateOpt string parameter in the Modify Command window, not in the report. If I comment out line 14 of the SQL the error does not occur.
    I have attached the SQL Code and screen shots of the errors.   Please tell me what I am doing wrong.

    Since your parameter is of type STRING, you need to enclose references to it within the Command inside single quotes.
    For example, instead of
    SET @BeginDate ={?BeginDate}
    use
    SET @BeginDate ='{?BeginDate}'
    hth,
    - ido

  • Hide or delete column (linked to item with edit menu) in power shell

    Hi;
    How in powerShell can I change the column in a SharePoint list that has the link to the item and the link to the item with edit menu.
    For examlpe :
    Title (linked to item) and Title (linked to item with edit menu)
    I want to add into my view only the Title (linked to item) : ViewFields.Add("Title(linked to item)")
    Thanks

    The name of the field which needs to be deleted is LinkTitle. Here is a sample PowerShell code:
    $web = Get-SPWeb "http://aissp2013/sites/TestSite"
    $list = $web.Lists["XYZ"]
    $view = $list.Views["All Items"]
    $view.ViewFields.Delete("LinkTitle")
    $view.Update()
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • Add workflow to contenttype by share-point power shell script

    Hello,
      I need to add work flow "Publish Approval" to content type by SharePoint power shell script .
      how Can I implement that ?
    ASk

    Hi,
    According to your post, my understanding is that you want to add the workflow to a content type using PowerShell script.
    The following PowerShell script for your reference:
    function AddWorkflowToContentType($site, $ctName, $WfName, $WfAssociationName, $TaxTaskList)
    [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
    [void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Policy')
    [Guid]$wfTemplateId = New-Object Guid
    $web = $site.RootWeb
    $ct = $web.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = $TaxTaskList
    $historylist = "IP Workflow History"
    # Workflow Association with Content Type
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateSiteContentTypeAssociation($template, $WfAssociationName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $false
    $association.AutoStartCreate = $true
    $ct.AddWorkflowAssociation($association)
    $ct.UpdateWorkflowAssociationsOnChildren($true, $true, $true, $false)
    $association.Enabled=$true
    $ct.Update()
    $web.Update()
    else
    Write-Error "Workflow Template not found"
    Add-Content $logFileName "Workflow Template not found."
    More information is here:
    http://anujabhojani.blogspot.com/2013/04/powershell-to-attach-workflow-on.html
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Trying to run program off network location using GPO with Power shell script.

    Hello All,
    Not much of a script writer. I am giving it a shot.  My issue is that I need to run a application update across our network and I am trying to do it with as little hands on as possible. So I was planning to push a GPO with a power shell script in it
    to run the program with elevated privileges. 
    Little background:
    We are running on a domain and end users do not have admin rights.
    The application is stored on a share on our network that is open to all domain users.
    The installer user name and password is a temp one and will only be valid for the 30 min window when everyone logs in at the beginning of the day.
    So this is what I have so far.
    $username = "USER"
    $password = "PASSWORD"
    $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
    Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDirectory \\Server\Folder\Folder1\Folder2\filder3\PSQLv11sp3_x32\
    But for some reason I keep getting :
    Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
    At line:10 char:1
    + Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDir ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    Any help you could give would be great.
    Thanks,
    jdfmonkey

    Hi jdfmonkey,
    Has anyone provided an answer to your original question?  I am trying to use Start-Process to launch a process using another logged in user's credentials, and am not able to get it working:
    $cred=Get-Credential
    start-process Process.exe-WorkingDirectoryC:\Scripts-Credential$cred
    I get the same error that you mentioned:
    start-process : This command cannot be run due to the error: The system cannot find the file specified.
    At C:\Scripts\Process.ps1:2 char:1
    + start-process Process.exe -WorkingDirectory C:\Scripts -Credential ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    When I leave off the credentials:
    start-processProcess.exe-WorkingDirectoryC:\Scripts
    It works correctly.  Does anyone have a solution to make this work correctly?
    Please ask your own question.  You issue is nothing like the current thread.  You clearly are using a user account that has no access to the folder.  It is a permissions issue.  It is not a scripting issue.
    If you need further help please start your own question.
    ¯\_(ツ)_/¯

  • To integrate power shell with visual studio

    How to integrate power shell with visual studio.

    We do have a Add in available for Visual Studio - this is not for building GUI
    https://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597
    Are you looking for Windows Forms? or WPF?
    If WPF see the example code below
    https://gallery.technet.microsoft.com/WPF-Windows-Presentation-720ff7ee
    Regards Chen V [MCTS SharePoint 2010]

  • Power Shell script to send a email with event details when an specified event occur

    I want a power shell scrip to send a email to a specific email id with the event details when an specified event triggered. The default option to trigger the email on event occur is failed.

    Why is everybody now saying "I want, I want, I want"
    Can you say what is happening?  Can you post a script with a line that is failing?  No!  All you want is a free script.
    Start by learning how to script.   Try at least to write a simple "hello World" script.  Until then you cannot post here.
    ¯\_(ツ)_/¯

  • Problem with String variable

    I am new to Java Programming.
    I have a line of code that works and does what is supposed to.
    faceData.getProfile("Lisa").removeFriend("Curtis");
    If I assign the strings to variables such as-
    String name = "Lisa";
    String fName = "Curtis";
    and then plug those into the same line of code, it does not work
    faceData.getProfile(name).removeFriend(fName);
    What could be causing the problem?
    I even added some lines to print out what is stored in the variables to verify that they are what they should be, but for some reason the variables do not work while putting the strings in quotes does. Any ideas?

    I guarantee that something about your assertions are incorrect. Those variables are either not equal to the values you claim, or something else is going on. But it's not a problem with string variables versus string constants.
    Edit: My best guess in lack of a real example from you, is that the strings in question have non-printable characters in them, such as trailing spaces or line feeds.

  • Create & Start UPS Service Using Power-Shell in SharePoint 2013

    I want to know that is there a way to create a User Profile Synchronization Service using Power-Shell in a SharePoint 2013 Enterprise site? If so then how am I supposed to do that and start the User Profile Synchronization Service using the Power-Shell.
    I'm seeking this help because the UPS service is stuck in Starting and both FIM Services are also not started but they are in Automatic start mode.
    Could someone try to solve this matter.
    Thanks,
    regards,
    Chiranthaka

    start it from powershell will not help you resolve the issue.
    Try below articles:
    http://myspexp.com/2011/04/28/user-profile-synchronization-servicehangs-on-starting-i-fixed-it/
    troubleshoot this issue:http://www.harbar.net/articles/sp2010ups2.aspx
    http://www.sharepointdiary.com/2012/09/user-profile-synchronization-service-stuck-at-starting.html#ixzz2aXArH7zX

  • Using Power shell script how to hidden SharePoint existing features.

    Hi Firends,
    Using Power shell script how to hidden SharePoint existing features.
    Please help me.
    Thanks,
    Tiru
    Tiru

    The Hidden property is set within the solution, so you would need access to the source code in order to set it.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • How to concatenate a "name.target" with string?

    Hello, how are you?
    I have this issue:
    I have a function -let's call this function "dad", that receives a parameter -let's call it "parameter". Inside dad function, I need to concatenate parameter with a string, to call a function outside function dad. Example:
    function dad (parameter) {
    parameter.target.onPress = trace (parameter.target  + "_animation") --> this returns "_level0.button1_animation" which is the same as "button1_animation" right?
    but when i use it to call a function outside it doesnt work:
    parameter.target.onPress = parameter.target + "_animation" ; --> doesn't work.
    parameter.target.onPress = [parameter.target + "_animation"] ; --> doesn't work.
    but this does work:
    parameter.target.onPress = button1_animation
    function button1_animation {
    here i have a tween
    All i wanna do, is concatenate parameter.target with a string, to call a function outside! is it possible ?
    thanks in advance

    Ned, Thanks.
    I dont want to treat the string as a function, because I already have the function "button1_animation" outside. I need to call that function  when i do parameter.target.onPress where parameter is button1, button2, button3 (i am passing to the parameter an array of buttons, and i need each button to call it's own function (button1_animation, button2_animation, an so on...) this functions are outside the function  that receives "parameter".
    I finally could do it this way:
    parameter.target.onPress = eval[parameter.target_name + "_animation"]
    i really appreciate the time you took on helping me. Thank you very much.

  • App-V 5 Client with Power Shell 4.0

    We are currently running App-V 4.6 SP2 on our Windows 7 SP1 x64 Clients. We just upgraded to Configuration Manager 2012 R2 which we also use to deploy app-v packages.
    Now i'm planning to upgrade our clients to "App-V 5.0 SP2". A prerequisite for App-V 5 is Power Shell 3.0 / .NET Framework 4.0
    Currently there is already PowerShell 4.0 and .NET Framework 4.5.1 available for Windows 7. Are those components supported with App-V 5.0 SP2 on Windows 7?
    Thanks :)

    Yes, this will work. These are the versions that come with Windows 8/8.1 etc.
    Please remember to click "Mark as Answer" or "Vote as Helpful" on the post that answers your question (or click "Unmark as Answer" if a marked post does not actually
    answer your question). This can be beneficial to other community members reading the thread.
    This forum post is my own opinion and does not necessarily reflect the opinion or view of my employer, Microsoft, its employees, or other MVPs.
    Twitter:
    @stealthpuppy | Blog:
    stealthpuppy.com |
    The Definitive Guide to Delivering Microsoft Office with App-V

  • Network-Shared Variable - read string with CVI

    I need to read an NSV string with CVI.  I have been digging into accessing and writing NSV with CVI, but they are all scalar value.  What should I do with strings, clusters and arrays?

    'm an employee at National Instruments and I wanted to make sure you didn't miss the Network Variable API that is provided with LabWindows/CVI, the National Instruments C development environment. The the Network Variable API will allow you to easily communicate with the LabVIEW program over Shared Variables (http://zone.ni.com/devzone/cda/tut/p/id/4679). While reading these links, note that a Network Variable and a Shared Variable are the same thing - the different names are unfortunate...
    The nice thing about the Network Variable API is that it allows easy interoperability with LabVIEW, it provides a strongly typed communication mechanism, and it provides a callback model for notification when the Network/Shared variable's properties (such as value) change.
    You can obtain this API by installing LabWindows/CVI, but it is not necessary to use the LabWindows/CVI environment. The header file is available at C:\Program Files\National Instruments\CVI2010\include\cvinetv.h, and the .lib file located at C:\Program Files\National Instruments\CVI2010\extlib\msvc\cvinetv.lib can be linked in with whatever C development tools you are using.
    Thomas N.
    Applications Engineer
    National Instruments

  • Good practice to initalize all instance variables with type String to emptr

    Is it a good practice to initalize all instance variables with
    type String to emptry string?
    #1 approach:
    public class A
    { private String name = "";
    private String address ="";
    //etc...
    rather than
    #2 approach:
    public class A
    { private String name;
    private String address;
    //etc...
    When I read Java books, the examples don't usually do #1 approach.
    The problem is if we don't initialize to empty string, when we call
    the getter method of that instance variable, it will return null.
    Please advise. Thanks!!

    Please advise. Thanks!!It depends on your coding style. If you can avoid lots of checks for null Strings in the rest of the code then why not initialize to "".
    You have the same situation when a method returns an array. If you under circumstances return a null array reference then you have to always check for this special case, but if you return a zero length array instead you have no special case. All loops will just run 0 iterations and everything will work fine.
    So in general I guess the return of zero objects instead of null references really boils down to whether it simplicates the rest of your code by removing lots of extra checks for the special null case. This usage is especially favourable in the zero length array case. See Effective Java by Bloch, item 27.

  • Concatenate sysdate with file name in shell script

    Hi,
    I have one shell script which i am using to transfer data(SFTP).
    Now I have one requirment to use sysdate along with the file name as the file name for the data being transfered.
    script is like this...
    function connect
    sftp $USER@$HOST <<END_SCRIPT
    lcd $FILE_DIR
    if [ $FILE="PO" ] then
    quote site recfm=fb
    quote site lrecl=230
    pwd
    put $FILE 'OPENPO'
    fi
    quit
    END_SCRIPT
    Can any one tell how i can concatenate sysdate with the file name (put $FILE 'OPENPO')?
    Thanks in Advance,
    RR

    it gets even easier with the 'scp' command.
    please try to use the "code" tags. it is very well possible the forum software did transform parts of your script.
    to get into 'code mode': put { c o d e } on a line (without the spaces), then the code, then { c o d e } again to switch back to normal mode.

Maybe you are looking for

  • RE: Can't install OS 9 from Software Restore discs

    I noticed this post: http://discussions.apple.com/thread.jspa?threadID=260277 I was having the same issue, but managed to figure it out. That post has been archived, so thought I would note my method in a new post. OK, so you've installed OS X 10.4 T

  • Error in Running Scrren Painter

    Dear All, I am facing a problem regarding screen painter. Source of Error: - T-Code -se80 -> Program with Prog name ->Activate ->Clicking on Layout it is giving a error i.e.                <b>GUI 640 Patches 4274 smaller than required(8)</b> This err

  • My powerbook is just about to run out of space!

    any ideas for how i can store all my files, photos, songs, movies...etc. thanks

  • HUD disappeared (Ap 2)

    Any ideas why the HUD doesn't appear even when the menu implies it is visible (i.e. it shows "Hide inspector HUD")? The other HUDs work fine. Thanks

  • Displaying command line window in a tab

    I have to display a graphics screen of a simulator that is run through a batch file, in a tab. Is it possible? If yes how might I do so? Thanks for you time!