none
Creating Batch file of a powershell command (Extracting Solution Packages (WSPs) from SharePoint using PowerShell) RRS feed

  • Question

  • Hi,

       I want to create Batch File (Extracting Solution Packages (WSPs) from SharePoint using PowerShell)

                Here is my power shell command -

    Add-SPSolution -c:\SharePointMultipleFileUploader.wsp

    Install-SPSolution –Identity SharePointMultipleFileUploader.wsp –WebApplication http://spserver:2999 –GACDeployment

    Enable-SPFeature –Identity SharePointMultipleFileUploader_Feature1 –http://spserver:2999/Site/User


    now i want to create .bat file .

    Thanks

    Mukesh


    Thanks Mukesh

    Friday, August 19, 2016 10:08 AM

Answers

  • Hi Mukesh,

    This is simple.

    1. Please copy all your commands in notepad file.

    2. Rename that as .ps1 file.

    3. Create a .bat file like below to run the powershell commands

    @pushd "C:\myscripts"
    powershell .\test.ps1 arg1 
    @popd

    4. Schedule the .bat file or run it on command prompt

    Thanks

    Kailas

    ---------------------------------------------------------------

    Please Vote or Mark as an Answer 

     

    Friday, August 19, 2016 10:52 AM

All replies

  • Hi Mukesh,

    This is simple.

    1. Please copy all your commands in notepad file.

    2. Rename that as .ps1 file.

    3. Create a .bat file like below to run the powershell commands

    @pushd "C:\myscripts"
    powershell .\test.ps1 arg1 
    @popd

    4. Schedule the .bat file or run it on command prompt

    Thanks

    Kailas

    ---------------------------------------------------------------

    Please Vote or Mark as an Answer 

     

    Friday, August 19, 2016 10:52 AM
  • Hi,

    $dirName = "<directory path>" 

    Write-Host Exporting solutions to $dirName  

    foreach ($solution in Get-SPSolution)  

    {  

        $id = $Solution.SolutionID  

        $title = $Solution.Name  

        $filename = $Solution.SolutionFile.Name 

        Write-Host "Exporting ‘$title’ to …\$filename" -nonewline  

        try {  

            $solution.SolutionFile.SaveAs("$dirName\$filename")  

            Write-Host " – done" -foreground green  

        }  

        catch  

        {  

            Write-Host " – error : $_" -foreground red  

        }  

    }

     I want to create Batch File (Extracting Solution Packages (WSPs) from SharePoint using PowerShell)


    Thanks Mukesh

    Friday, August 19, 2016 10:58 AM
  • Hi Mukesh,

    Do you mind sharing the whole solution here and mark it as answer? It would make others who stuck with the similar issue easier to find a valid solution in this forum.

    Best regards,

    Patrick


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Monday, August 22, 2016 8:18 AM
    Moderator