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