1+ Register-MSConfigStore ;
2+
3+ Set-MSConfigDebugMode - Value ($false ); # $true oder $false
4+
5+ Register-MSSession - UseDefaults ($true );
6+ Select-MSSession - UseDefaults ($true );
7+ Enter-MSSession - UseDefaults ($true );
8+
9+ # GUID des Projektes im Format 09dd6c35-ad5d-4905-ab0f-4fbc0a37f61c oder 09DD6C35AD5D4905AB0F4FBC0A37F61C
10+ # $WSMProjectGUID = ("072d6659-a806-425b-aca8-d29f37fd6e7d"); # Vodafone Internet
11+ # $WSMProjectGUID = ("6A89CD93325D42FD81A42FA836547016"); # Vodafone Internet - Fachhandel Online
12+ # $WSMProjectGUID = ("107CB9590FBB4C1AB7B8F7FE2449EE85"); # Vodafone Internet - Innovation Park
13+ # $WSMProjectGUID = ("8C681C01ECE44FC8B1FB45C4A7760501"); # Vodafone Intranet (AskVodafone)
14+ # $WSMProjectGUID = ("BA2A9869B57D4BA89E598F6B4B48F0B6"); # Vodafone Mobile
15+ # $WSMProjectGUID = ("771B99172E8B404794FA805EF961EF57"); # vodafone Applications - MobileApp
16+ # $WSMProjectGUID = ("8A300F4B74AA4D4CB5C54C2165FC56D1"); # Shared Components - Simplicity
17+ # $WSMProjectGUID = ("09754F11ECFB485E98AA72853155CB00"); # Shared Data - Tariff Details
18+ $WSMProjectGUID = (" 7C503F8E943E4E6CACE63B2DEB82BBF4" ); # Development - Defects and Testing
19+
20+ $Result = Enter-MSProject - ProjectGUID ($WSMProjectGUID );
21+ $ResultProject = ($Result ).SelectNodes(" IODATA/PROJECT" );
22+ $ResultProject.name ;
23+
24+ $Counter = 0 ;
25+ $CountTotal = 0 ;
26+ $Date = (" 31.12.2018" );
27+
28+ $DisconnectedPages = @ ();
29+ $SkippedPages = @ ();
30+
31+ $ValuePercentComplete = 0 ;
32+ Write-Progress - Activity (" Working..." ) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - collecting data." );
33+ $ExpiredPages = (Find-MSPagesLinkingSchedule - PageSize (2000 ) - MaxHits (2000 ) - LinkingScheduleDate (Get-Date - Date ($Date ))).SelectNodes(" IODATA/PAGES/PAGE" );
34+
35+ $WorkingStep = (99 / $ExpiredPages.Count );
36+ $ValuePercentComplete = 1 ;
37+ Write-Progress - Activity (" Working..." ) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - Found {0} expired pages in project {1}" -f ($ExpiredPages.guid ).Count, ($ResultProject.name ));
38+ $CountTotal += $ExpiredPages.Count ;
39+
40+ foreach ($ExpiredPage in $ExpiredPages ) {
41+ $Counter ++ ;
42+ Write-Progress - Activity (" Working... (Disconnected pages {0} | Skipped pages {1} | Found {2} expired pages in project: {3})" -f ($DisconnectedPages ).Count, ($SkippedPages ).Count, ($ExpiredPages.guid ).Count, ($ResultProject.name )) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - ({1}) - check linking of page: {0}." -f $ExpiredPage.headline , $Counter );
43+ $CountLinking = (Get-MSPageLinkingAppearanceSchedules - PageGUID ($ExpiredPage.guid )).SelectNodes(" IODATA/LINKSFROM/LINK" );
44+ if ($CountLinking.Count -eq 1 ) {
45+ Write-Progress - Activity (" Working... (Disconnected pages {0} | Skipped pages {1} | Found {2} expired pages in project: {3})" -f ($DisconnectedPages ).Count, ($SkippedPages ).Count, ($ExpiredPages.guid ).Count, ($ResultProject.name )) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - ({1}) - check linking of page: {0}." -f $ExpiredPage.headline , $Counter );
46+ $DisconnectedPages += $ExpiredPage ;
47+ $Result = Disconnect-MSPage - PageGUID ($ExpiredPage.guid ) - LinkGuid ($ExpiredPage.mainlink );
48+ }
49+ else {
50+ Write-Progress - Activity (" Working... (Disconnected pages {0} | Skipped pages {1} | Found {2} expired pages in project: {3})" -f ($DisconnectedPages ).Count, ($SkippedPages ).Count, ($ExpiredPages.guid ).Count, ($ResultProject.name )) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - ({1}) - check linking of page: {0}." -f $ExpiredPage.headline , $Counter );
51+ # Write-Output ("GUID: {2} | Total: {0} | Expired: {1}" -f $CountLinking.Count, ($CountLinking | Where-Object { $_.dateend -ne "0" }).Count, $ExpiredPage.guid);
52+ # $CountLinking | Select-Object -Property "dateend" | Where-Object { $_.dateend -le (ConvertTo-OADate -Date (Get-Date -Date ($Date))) };
53+ $SkippedPages += $ExpiredPage ;
54+ }
55+ $ValuePercentComplete += $WorkingStep ;
56+ }
57+
58+ Write-Progress - Activity (" Finished..." ) - PercentComplete ($ValuePercentComplete ) - CurrentOperation (" {0}% complete" -f [math ]::Round($ValuePercentComplete )) - Status (" Please wait - Sending output to console." );
59+
60+ $DisconnectedPages.Count ;
61+ $SkippedPages.Count ;
62+
63+ # $DisconnectedPages | Select-Object -Property ("guid", "mainlink", "id", "headline") | Format-Table; # Optional
64+ $DisconnectedPages | Select-Object - Property (" guid" , " mainlink" , " id" , " headline" ) | Format-Table | Out-File - FilePath (" C:\Temp\Result-RemovedExpiredPages-{0}-{1}.txt" -f $WSMProjectGUID , (Get-Date - Format (" yyyyMMdd-HHmmss" ))) - Encoding (" utf8" ) - Force; # Optional - Output to file (txt)
65+ Export-Clixml - InputObject $DisconnectedPages - Path (" C:\Temp\Result-RemovedExpiredPages-{0}-{1}.xml" -f $WSMProjectGUID , (Get-Date - Format (" yyyyMMdd-HHmmss" ))) - Force; # Optional - Output to file (object)
66+
67+ # Show-MSSession; # Optional
68+ Exit-MSSession - UseDefaults ($true );
69+ Unregister-MSSession - UseDefaults ($true );
70+
71+ Unregister-MSConfigStore ;
0 commit comments