One of the things that annoyed me with PowerShell and SharePoint are the following commands:-
- Actually anything that requires a –LiteralPath parameter
Don’t get me wrong I think that using PowerShell to admin SharePoint is fantastic but these commands bug me because they require a full path to work correctly. Unfortunately you don’t seem to be able to use the full stop (or period) to represent the current directory.
So you cannot do something like this:-
Instead you need to do this:-Add-SPSolution c:\thisisareallylongpath\release1\section2\mysharepoint.wsp
Anyway, that got me thinking surely there is a better way and I can save myself some typing.
The solution is to use the command Get-Location.
So instead you can do this:-$curdir = Get-Location; Add-SPSolution–LiteralPath $curdir”\mysharepoint.wsp”;
Actually there is a PowerShell Alias called gl which is a shortcut for the Get-Location command.
So the shortest version in terms of saving your typing fingers is this:-$curdir = gl; Add-SPSolution –LiteralPath $curdir”\mysharepoint.wsp”;
Really hope that helps save you some time, also love to hear any other alternatives, there is bound to be an even better way of doing this.51.616699 0.316700
Nice tip on Get-Location – I hadn’t used that before. Have you tried the Resolve-Path command too? I haven’t re-checked this yet but I think with Resolve-Path you will be able to do something like:
Add-SPSolution -LiteralPath (Resolve-Path .\mysharepoint.wsp)
Cheers for the tip – nice!
I’ll give it ago tommorrow.
I’ve just been using Powershell and Add-SPSolution…I totally agree that having to actually type the literal path seems pointless..
Thanks for the comment Steve – hope all going well in Marylebone!
Are you still in Marylebone? I’m running through an install guide you wrote just now – the “BI Deployment guide”
(Jan release ver 0.8)