Produced by Araxis Merge on 7/17/2018 6:16:26 PM Eastern Daylight 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\module | RAMS_Module_CleanHistory.psm1 | Tue Apr 24 01:38:34 2018 UTC |
2 | RAMS-2.3.0.zip\RAMS-2.3.0\ps\module | RAMS_Module_CleanHistory.psm1 | Tue Jul 17 20:14:13 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 356 |
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 | Set-Strict Mode -Vers ion Latest | |
3 | ||
4 | $ArrayList = New-Obj ect System .Collectio ns.ArrayLi st | |
5 | ||
6 | function G et-ColumnV alueFromAL ist ($Site , $subSite , $filterD ate, $list Url, $list Name, $lis tColumnNam e) | |
7 | { | |
8 | #get a collectio n of ids | |
9 | $items ToDelete = New-Objec t System.C ollections .ArrayList | |
10 | $list = Get-SPLi st -web $S ite -Name $listName -Url $list Url -subWe b $subSite | |
11 | #get a pplication list | |
12 | if($li st -ne $nu ll) | |
13 | { | |
14 | #G et all ite ms in this list and save them to a varia ble | |
15 | $i tems = $li st.items | |
16 | $i temCount = 0 | |
17 | #G o through all items | |
18 | Wr ite-Host T otal Items in the $l ist.Entity TypeName : $items.Co unt -Foreg roundColor Green | |
19 | fo reach($ite m in $item s) | |
20 | { | |
21 | if($item ["Created" ] -lt $fil terDate) | |
22 | { | |
23 | #add each item id to the delete li st | |
24 | Writ e-Host Add item# $it emCount f rom the li st for Stu dy#: $item ["Title"] on $item[" Created"] -Foregroun dColor Cya n | |
25 | $ite msToDelete .Add($item [$listColu mnName]) | |
26 | $ite mCount ++; | |
27 | } | |
28 | } | |
29 | #n ow start d eleting th ose items | |
30 | if ($itemCoun t -eq 0) { | |
31 | Write-Ho st Nothing to delete , count: $ itemCount -Foregrou ndColor Ye llow | |
32 | r eturn | |
33 | } | |
34 | Wr ite-Host T otal items to be del eted $item Count -Fo regroundCo lor Yellow | |
35 | } | |
36 | else | |
37 | { | |
38 | Wr ite-Host N o list fou nd by the name: $lis tUrl | |
39 | } | |
40 | return $itemsToD elete | |
41 | } | |
42 | function R emove-Data FromAListB yColumn ($ Site, $sub Site, $Col umnSet, $l istUrl, $l istName, $ listColumn Name) | |
43 | { | |
44 | #get a collectio n of ids | |
45 | $items ToDelete = New-Objec t System.C ollections .ArrayList | |
46 | $list = Get-SPLi st -web $S ite -Name $listName -Url $list Url -subWe b $subSite | |
47 | #get a pplication list | |
48 | if($li st -ne $nu ll) | |
49 | { | |
50 | #G et all ite ms in this list and save them to a varia ble | |
51 | $i tems = $li st.items | |
52 | $i temCount = 0 | |
53 | #G o through all items | |
54 | Wr ite-Host T otal Items in the $l ist.Entity TypeName : $items.Co unt -Foreg roundColor Green | |
55 | fo reach($ite m in $item s) | |
56 | { | |
57 | foreach( $col in $C olumnSet) { | |
58 | $x = $item.Url | |
59 | if($ x.IndexOf( "/Study") -gt 0) { | |
60 | $studyId = $x.Substr ing($x.Ind exOf("/")+ 1,$x.Index Of("/Study ")-$x.Inde xOf("/")-1 ) | |
61 | if($studyI d -eq $col ) | |
62 | { | |
63 | #add e ach item i d to the d elete list | |
64 | Write- Host Add i tem# $item Count fro m the list for Study #: $item[" Title"] on $item["Cr eated"] -F oregroundC olor Cyan | |
65 | $items ToDelete.A dd($item.I D) | |
66 | $itemC ount ++; | |
67 | } | |
68 | } | |
69 | } | |
70 | } | |
71 | #n ow start d eleting th ose items | |
72 | if ($itemCoun t -eq 0) { | |
73 | Write-Ho st Nothing to delete , count: $ itemCount -Foregrou ndColor Ye llow | |
74 | r eturn | |
75 | } | |
76 | Wr ite-Host T otal items to be del eted $item Count -Fo regroundCo lor Yellow | |
77 | fo reach($ite mToDelete in $itemsT oDelete) { | |
78 | Write-Ho st Deletin g item# $i temToDelet e -Foregro undColor C yan | |
79 | $items.D eleteItemB yId($itemT oDelete); | |
80 | } | |
81 | $i tems.Updat e(); | |
82 | $l ist.Update (); | |
83 | Wr ite-Host T otal Items After $li st.items.C ount -For egroundCol or Green | |
84 | } | |
85 | else | |
86 | { | |
87 | Wr ite-Host N o list fou nd by the name: $lis tUrl | |
88 | } | |
89 | return $itemsToD elete | |
90 | } | |
91 | ||
92 | function R emove-RAMS HistoryDat a ($cleanD ate, $dbSe rver) | |
93 | { | |
94 | #get s ite collec tion | |
95 | #$site = Get-SPS ite -Limit All | Sel ect-String IRBApplic ations | |
96 | $site= Get-SiteU RL | |
97 | $x = $ site.ToStr ing(); | |
98 | $url = $x.Substr ing($x.Ind exOf("=")+ 1) | |
99 | #$w = Get-SPWeb $url | |
100 | $w = G et-SiteWeb | |
101 | ||
102 | #filte r by days | |
103 | $filte rPriorDate = $cleanD ate | |
104 | Write- Host "Dele te data be fore $filt erPriorDat e" -Foregr oundColor Magenta | |
105 | ||
106 | ||
107 | #Delet e Applicat ion list f or older s tudies. | |
108 | $listU rl = $url + "/Lists/ Applicatio n/AllItems .aspx" | |
109 | $listO fStudies = Get-Colum nValueFrom AList -Sit e $w -filt erDate $fi lterPriorD ate -listU rl $listUr l -listCol umnName "S tudy_ID" | |
110 | ||
111 | Remove -DataFromA List -Site $w -filte rDate $fil terPriorDa te -listUr l $listUrl | |
112 | ||
113 | #Delet e workflow task list | |
114 | $listU rl = $url + "/Workfl owTasks/Al lItems.asp x" | |
115 | Remove -DataFromA List -Site $w -filte rDate $fil terPriorDa te -listUr l $listUrl | |
116 | ||
117 | #Delet e Shared D ocs for th e same set of studie s | |
118 | $listU rl = $url + "/Shared %20Documen ts/Forms/A llItems.as px" | |
119 | Remove -DataFromA List -Site $w -filte rDate $fil terPriorDa te -listUr l $listUrl | |
120 | Remove -DataFromA ListByColu mn -Site $ w -ColumnS et $listOf Studies -l istUrl $li stUrl -lis tColumnNam e "Name" | |
121 | ||
122 | #delet e items fr om list at sub-site level | |
123 | $listB ucket = @( | |
124 | "FullB oardReview Calendar", | |
125 | "Commi tteeMinute s", | |
126 | "DataS haringRepo sitoryAgre ements", | |
127 | ||
128 | "IACUC Calendar" , | |
129 | ||
130 | "RDC C alendar", | |
131 | ||
132 | "SRSCa lendar" | |
133 | ); | |
134 | ||
135 | $formBuc ket = @( | |
136 | "IACUC Documents" , | |
137 | ||
138 | "RDCAg enda", | |
139 | "RDCDo cuments" | |
140 | ||
141 | "RCOCh ecklists" | |
142 | ); | |
143 | ||
144 | foreac h($sub in $w.Webs) { | |
145 | #D elete list data | |
146 | fo reach($lis tEgg in $l istBucket) { | |
147 | $listUrl = $sub.ur l + "/List s/" + $lis tEgg + "/A llItems.as px" | |
148 | Remove-D ataFromALi st -filter Date $filt erPriorDat e -listNam e $listEgg -listUrl $listUrl - subSite $s ub | |
149 | } | |
150 | #D elete form data | |
151 | fo reach($for mEgg in $f ormBucket) { | |
152 | $listUrl = $sub.ur l + "/" + $formEgg + "/Forms/A llItems.as px" | |
153 | Remove-D ataFromALi st -filter Date $filt erPriorDat e -listNam e $formEgg -listUrl $listUrl - subSite $s ub | |
154 | } | |
155 | } | |
156 | #clean from sql server | |
157 | $recAf fected = RunSQL-Ret urnInt -sq lQuery "ex ec DataCle anup @cuto ffdate='$c leandate'" -dbServer $dbServer | |
158 | Write- Host "Tota l $recAffe cted Studi es have be en deleted from the RAMS user database:" -Foregrou ndColor Ye llow | |
159 | } | |
160 | ||
161 | Export-Mod uleMember Remove-RAM SHistoryDa ta | |
162 | ||
163 | <# | |
164 | e.g. Remov e-RAMSHist oryData -c leanDate " 12/30/2015 12:56:20" -dbServer DN S | |
165 | ||
166 | New-Module Manifest - Path .\RAM S_Module_C leanHistor y.psd1 -Mo duleVersio n 1.0.0 -A uthor "Chi ta Nilak, ByLight" - RootModule .\RAMS_Mo dule_Clean History.ps m1 -Descri ption "RAM S Utility Functions" -CompanyN ame "VA.GO V.RAMS" -V erbose | |
167 | cd.. | |
168 | if((Get-Mo dule -Name RAMS_Modu le_CleanHi story) -ne $null) { | |
169 | Remove -Module -N ame RAMS_M odule_Clea nHistory | |
170 | } | |
171 | try { | |
172 | Import -Module .\ RAMS_Modul e_CleanHis tory.psd1 | |
173 | } | |
174 | catch { | |
175 | Write- Host Host: $env:COMP UTERNAME i s not a Se rver, Shar ePoint is not instal led on thi s computer ...ignore, informati on only. | |
176 | #do no thing. | |
177 | } | |
178 | ||
179 | #> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.