Setting up PSake - powershell

Does anybody know or have a link to how I set up psake to run through powershell?
I have absolutely no idea and I can find nothing to tell me.

Download it from here. Here are some examples of its use:
http://ayende.com/Blog/archive/2009/08/30/on-psake.aspx
http://www.jameskovacs.com/blog/IntroducingPsake.aspx
The 2.0 version of PSake is a PowerShell module which requires PowerShell 2.0. Extract the contents of the PSake ZIP into $env:Home\Documents\WindowsPowerShell\Modules\PSake. Then you import it like so:
Import-Module PSake
Define a "properties" hashtable and then start using its exported commands like Task in your build scripts.

Related

How to install Selenium PowerShell eXtensions?

I'm trying to make a PowerShell script( here is the question about it )
somebody answer me, that I need to install Selenium PowerShell eXtensions
but I doesn't find the manual - "how to install a Selenium PowerShell eXtensions", Somebody please help!
There isn't an install guide specifically for Selenium as it's just a standard powershell module and they are all imported with the same command.
Download the zip from codeplex, extract it and then import the module (substituting the path for yours):
If you call the folder SePSX you can use this:
Import-Module "C:\folder\SePSX"
Any other name use this:
Import-Module "C:\folder\Selenium\SePSX.dll

Importing Sharepoint modules in TFS Powershell build script

I'm trying to run a release in TFS to Sharepoint Online and I can't seem to import and load the module.
I tried just a straight import-module statement:
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
I the found this solution but that's not playing ball either.
How to load PowerShell Module from custom script on vNext build agent?
You will have to load the assembly before you can use the types inside it.
You can use the loadfile method,
[Reflection.Assembly]::LoadFile(“c:\folderwhereyouhavesharepointassemblies/thedllname.dll”)
Import-Module Microsoft.Online.SharePoint.PowerShell

Is there way to know cmdlet version in Powershell for backward compatibility?

Say you are scripting in Powershell 4.0 environment and you want to make sure the script works in Powershell 3.0. How do you ensure its backward compatible?.
Ok the question as phrased is a little more specific into what you are looking for. Sounds like you are asking for requires.
The#Requires statement prevents a script from running unless the Windows
PowerShell version, modules, snap-ins, and module and snap-in version
prerequisites are met. If the prerequisites are not met, Windows PowerShell
does not run the script.
That way, while you are scripting, you can enforce the functional version of your script.
#Requires -Version 3.0
So now while you are building and debugging your script you know that it will work on systems with at least 3.0. It recognizes minor builds as well if that matters.
I recently came across this requirement for my own needs and realize now that what I suggested up above will not get you the exact results I think you are looking for. What you should do instead is when you run your script call a new PowerShell session and use the -Version switch which Starts the specified version of Windows PowerShell(TechNet).
So when you are testing your script run it like this:
powershell -Version 2 -File myscript.ps1
Here an example to get the Version of "Get-ChildItem":
(Get-Command Get-ChildItem).Version
using get-module of the required Command, you can do it like:
(Get-Module (Get-Command Get-NetTCPConnection).Source).PowerShellVersion
For clarification:
(Get-command <your cmdlet>). Source gives you the installed location

TFS post build powershell script not seeing commands from imported module

We have a TFS build process using a custom template. The build works fine with the crm solution files successfully being created. We are then attempting to run a powershell script on the post build. This script imports a module. But the commands in the module are not being exposed. Whenever we attempt to invoke a command, we get an error. Along the lines of
The term 'Get-XrmSolution' is not recognized as the name of a cmdlet,
function, script file, or operable program.
It doesn't matter which command we use in that module, we get the same kind of error.
To troubleshoot, we have logged onto the build server under the identity of the build account and can successfully run the script we are attempting to run.
Putting some more output into the script to troubleshoot...
Get-Module lists Xrm.Framework.CI.PowerShell. - Good.
Get-Command -Module "Xrm.Framework.CI.PowerShell" returns nothing. From the console, a number of commands are listed.
Is there something we need to do with the running of powershell post build scripts to enable the contents of an imported module to be seen?
Watch out for the bitness of PowerShell invoked by MSBuild and likewise, the bitness of MSBuild launched by Visual Studio. Certain modules only run in either 32-bit or 64-bit PowerShell and not both. You want to make sure the correct version of PowerShell is getting launched.
IIRC you have to explicitly import the module with no assumption of being loaded on user profile, nor on the script path.
Suppose Module1.psm1 is in the same folder as your script, use something like
Import-Module (Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Definition) 'Module1.psm1')
I had the same problem.
The module was loaded in the 'C:\Program Files\WindowsPowerShell\Modules' folder (64 bits).
It all seemed fine when I logged on as the user, but it failed during TFS build.
Solution: I had to uninstall the module in PowerShell 64 bit and re-install in PowerShell 32 bit.
The module was then installed in 'C:\Program Files (x86)\WindowsPowerShell\Modules' folder.

Azure power shell cmdlet dll in .net project

Here I have a question about how to use Azure power shell cmdlet dll in .net project.
I got a look at this thread in msdn:
Use powershell cmdlet we can use this command.
Remove-AzureVM -ServiceName -Name
And this will involve the dll under Microsoft.WindowsAzure.Management.ServiceManagement.dll
which path is:
C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure
I use reflector open this dll.
And I can get the RemoveAzureVMCommand class, but how to use this class achieve the same thing as
powershell cmdlet?
Can some one share some light to me?
Thanks very much!
Azure PowerShell Cmdlets are essentially wrappers around Windows Azure Service Management API. What you could do is write your own C# code to invoke "Delete Role" (http://msdn.microsoft.com/en-us/library/windowsazure/jj157184.aspx) function which will remove the VM.
Hope this helps.