Produced by Araxis Merge on 11/9/2018 12:16:34 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | RAMS-2.3.0.zip\RAMS-2.3.0\ps\misc | CreateApplicationItem.v2.ps1 | Wed Aug 22 16:02:54 2018 UTC |
2 | RAMS-2.3.0.zip\RAMS-2.3.0\ps\misc | CreateApplicationItem.v2.ps1 | Fri Nov 9 14:36:48 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 186 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | <# | |
2 | .SYNOPSIS | |
3 | Utilit y and Test ing script to create an Applic ation List item | |
4 | ||
5 | .DESCRIPTI ON | |
6 | Used t o work out the defai ls for cre ating an a pplication list item . | |
7 | ||
8 | .EXAMPLE | |
9 | #when run from t he powersh ell comman d prompt. | |
10 | .\Crea teApplicat ionListIte m.v2.ps1 | |
11 | #> | |
12 | if ((Get-P SSnapin "M icrosoft.S harePoint. PowerShell " -ErrorAc tion Silen tlyContinu e) -eq $nu ll) { | |
13 | Add-PS Snapin "Mi crosoft.Sh arePoint.P owerShell" | |
14 | } | |
15 | ||
16 | ### ENVIRO NMENT SETT INGS | |
17 | $user = "d omain\user " | |
18 | $pass = "p assword" | |
19 | $ListName = "Applica tion" | |
20 | $url = "ht tps:// DNS . URL : PORT /sites/IRB Applicatio ns" | |
21 | ||
22 | ### TOGGLE DEBUG MOD E | |
23 | $debug = $ FALSE | |
24 | ||
25 | ### DO NOT MODIFY | |
26 | $headers = @{accept = "applica tion/json; odata=ver bose"} | |
27 | $formDiges t = $null | |
28 | $secPass = ConvertTo -SecureStr ing $pass -AsPlainTe xt -Force | |
29 | $cred = Ne w-Object S ystem.Mana gement.Aut omation.PS Credential ($user, $ secPass) | |
30 | ||
31 | function S etFormDige st() { | |
32 | $respo nse = Post Request (" /_api/cont extinfo") $null | |
33 | $formD igest = $r esponse.d. GetContext WebInforma tion.FormD igestValue | |
34 | $heade rs.Add("X- RequestDig est", $for mDigest); | |
35 | ||
36 | if ($d ebug) { | |
37 | Wr ite-Host " Form Diges t: " $form Digest | |
38 | } | |
39 | } | |
40 | ||
41 | function R equest ($e ndpoint, $ body, $met hod) { | |
42 | if ($d ebug) { | |
43 | Wr ite-Host " Endpoint: $endpoint, Method: $ method, Cr ed:" $cred .UserName -Backgroun dColor Gre en -Foregr oundColor Black | |
44 | Wr ite-Host " Header Key s:" $heade rs.Keys -B ackgroundC olor DarkG reen -Fore groundColo r Gray | |
45 | Wr ite-Host " Header Val ues:" $hea ders.Value s -Backgro undColor D arkGreen - Foreground Color Gray | |
46 | Wr ite-Host " Body Keys: " $body.Ke ys -Backgr oundColor DarkGreen -Foregroun dColor Gra y | |
47 | Wr ite-Host " Body Value s:" $body. Values -Ba ckgroundCo lor DarkGr een -Foreg roundColor Gray | |
48 | } | |
49 | try | |
50 | { | |
51 | re turn Invok e-RestMeth od -Uri ($ url+$endpo int) -Head ers $heade rs -Method $method - Body $body -Credenti al $cred - ContentTyp e "applica tion/json; odata=verb ose" | |
52 | } | |
53 | catch | |
54 | { | |
55 | Fa ilure | |
56 | } | |
57 | } | |
58 | ||
59 | function F ailure { | |
60 | #$global:h elpme = $b ody | |
61 | #$global:h elpmoref = $moref | |
62 | $global:re sult = $_. Exception. Response.G etResponse Stream() | |
63 | $global:re ader = New -Object Sy stem.IO.St reamReader ($global:r esult) | |
64 | $global:re sponseBody = $global :reader.Re adToEnd(); | |
65 | Write-Host -Backgrou ndColor:Bl ack -Foreg roundColor :Red "Stat us: A syst em excepti on was cau ght." | |
66 | Write-Host -Backgrou ndColor:Bl ack -Foreg roundColor :Red $glob al:respons ebody | |
67 | Write-Host -Backgrou ndColor:Bl ack -Foreg roundColor :Red 'Requ est Body:' $body | |
68 | break | |
69 | } | |
70 | ||
71 | ||
72 | function G etRequest ($endpoint , $body) { | |
73 | return Request $ endpoint $ body ([Mic rosoft.Pow erShell.Co mmands.Web RequestMet hod]::Get) | |
74 | } | |
75 | ||
76 | function P ostRequest ($endpoin t, $body) { | |
77 | return Request $ endpoint $ body ([Mic rosoft.Pow erShell.Co mmands.Web RequestMet hod]::Post ) | |
78 | } | |
79 | ||
80 | function C reateListI Tem($ListN ame, $item Title) { | |
81 | Write- Host "Crea ting Item' $itemTitle '" | |
82 | ||
83 | $respo nse = Post Request (" /_api/web/ lists/getb ytitle('" + $ListNam e + "')/it ems") (Con vertTo-Jso n @{ | |
84 | __ metadata = @{ type= 'SP.Data.A pplication ListItem' } | |
85 | Ti tle = $ite mTitle}) | |
86 | } | |
87 | ||
88 | ||
89 | ## Script Begin ## | |
90 | ||
91 | SetFormDig est | |
92 | $listitemT itle = "An Item-" + ( Get-Date). ToString() | |
93 | CreateList ITem $List Name $list itemTitle | |
94 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.