Powershell basic tasks

Merge Date and Time to DateTime

27/11/2013 11:23
Following date and time formats are used in InfoPath forms (value from Date or...

Remove item from array

31/08/2013 11:20
#Convert array to ArrayList to use 'Remove'...

Check absolute path in powershell

06/08/2013 14:54
Check if file or folder path is absolute or...

Create Shared folder

28/04/2013 11:17
Function New-SharedFolder ($FolderPath, $Sharename) {     # Test...

Remove folder recursive

28/04/2013 11:14
#Remove directory recursive, with read-only attributes #Go through all files...

Hash table array

02/03/2013 02:08
#Declare empty array with type to enable adding hashes [array]$arrayOfhashes =...

Zip folder with powershell

02/02/2013 05:51
Check if get-item is folder or file $file.PSIsContainer #property is true or...

Hash table in powershell

18/01/2013 15:11
#array of hash table $crawledProperties = (@{Name="ows_ChamLukasArticleDate";...

Remove slash from url

16/01/2013 13:57
#or there is mutch easiest way to do it with simple...

Compare powershell arrays

13/01/2013 09:08
$a=@("a", "b", "c") $b=@("x", "y", "z", "c", "u", "p", "i", "a"); $c=@("a",...
1 | 2 | 3 >>

Notes

Catch exception

12/10/2012 18:28
#save previous setting $defaultErrorAction=$ErrorActionPreference #Force program to catch exception in case of error $ErrorActionPreference="Stop" try { #use some method with specified exception     $item=$WorkItemStore.GetWorkItem(20156) } catch...

Ternary operator

06/08/2012 19:00
First run following definition      filter Invoke-Ternary ([scriptblock]  $decider,[scriptblock]$iftrue,[scriptblock]$iffalse)  {  if (&$decider) { &$iftrue} else { &$iffalse }  }   Then set alias for...

Apply function against an array

14/01/2012 00:10
function vypisParametrov {     param(         [string]$url,         [string]$nodeUrl,         [string]$nodeName     )     write-host "On...

Get site url from library url

13/01/2012 23:16
Get site url from library url    $libraryUrl="https://td_sp_ui/sites/test/CategoryCards/Pages"     #take site url from library url (one level folder)     $siteUrl=$libraryUrl.substring(0, $libraryUrl.LastIndexOf("/"));    ...

Remove, Add and Deploy solution

11/01/2012 14:15
Basic task against solution   List of solutions get-spsolution   If is deployed, uninstall it Uninstall-spsolution solutiionName.wsp -webapplication https://tdspui Remove-spsolution solutionName.wsp   Add new solution Add-SPSolution...

Get server and site name from url

09/01/2012 21:53
function GetServerNameFromUrl(     [string]$url ) { $server=$url.split("/") return $server[2] } function GetServerFromUrl(     [string]$url ) { $first=$url.IndexOf('/') $short=$url.substring($first+2,$url.length-$first-2) $server=$url.substring(0,...

pozn. k nastaveniu stylu stranky

07/01/2012 01:40
V .css file som zmenil nastavenie p  margin-botom na 0em pri #mainContent box_content p  line-height z 1.8em na 1.2em.

Feed choice menu with options

07/01/2012 01:36
#Feed choice menu with options. function SelectChoice {         param(         [array]$options         ) if(($options.length -gt 1))    ...

Others

Convert .cer file to .pfx

22/05/2018 12:12
There is cool article on https://blog.jayway.com/2014/09/03/creating-self-signed-certificates-with-makecert-exe-for-development/ how to make self signed certificate using makecert and pvk2pfx commands. But for access pvk2pxf you will need to instal Windows Driver Kit or some extensions...