Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
HowTo: Reading / Searching through XML Files
Logged in as: Guest
arrSession:exec spGetSession 2,5,62487
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Windows PowerShell
>> HowTo: Reading / Searching through XML Files
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
HowTo: Reading / Searching through XML Files -
7/18/2008 11:46:51 AM
turranx
Posts: 41
Score: 0
Joined: 2/7/2006
Status:
offline
The code on this page processes the output file generated by the code located here:
http://www.visualbasicscript.com/m_62022/tm.htm
#--------------------==--------------------# #-------------- Description --------------# # # This script takes an input file (example shown below) and looks # for any Public Folders where the items counts for all the # replicas are not identical. #--------------- Input File ---------------# # # The input file is generated from the output of my PowerShell script # Compare_Public_Folders_Between_Ex2000_and_Ex2007.ps1. An excerpt of # this file is shown below. # <?xml version="1.0" encoding="ISO-8859-1"?> # <Public_Folders> # <x /> # <Run_Details> # <Start> # <TimeStamp> # <Year>2008</Year> # <Month>7</Month> # <Day>15</Day> # <Time>13:28:23</Time> # </TimeStamp> # </Start> # <Finish> # <TimeStamp> # <Year>2008</Year> # <Month>7</Month> # <Day>15</Day> # <Time>15:23:26</Time> # </TimeStamp> # </Finish> # <Parameters> # <Connect_As_Identiy>UserID</Connect_As_Identiy> # <New_Server>NewMailServer</New_Server> # <Old_Server>OldMailServer</Old_Server> # <Security_Permission_Mode>Add</Security_Permission_Mode> # </Parameters> # </Run_Details> # <Public_Folder ID="3"> # <Name>Access Issues</Name> # <Path>\Access\Access Issues</Path> # <Friendly_Web_Address>HTTP://OldMailServer/public/Access/Access Issues</Friendly_Web_Address> # <Proper_Web_Address>HTTP://OldMailServer/public/Access/Access%20Issues</Proper_Web_Address> # <Replica> # <Server_Name>cocsxchng01</Server_Name> # <Web_Address_Header>http://OldMailServer</Web_Address_Header> # </Replica> # <Replica> # <Server_Name>NewMailServer</Server_Name> # <Web_Address_Header>https://NewMailServer</Web_Address_Header> # <Item_Count>26</Item_Count> # <Byte_Count>540999</Byte_Count> # </Replica> # </Public_Folder> #----------------- Output -----------------# # # This is an example of the output that is displayed on screen. # # Item Count mismatch for folder # \Finance\Conference Call Calendar # OldMailServer : 71 # NewMailServer : 55 # Item Count mismatch for folder # \Marketing\Administration\Team A # OldMailServer : 2655 # NewMailServer : 2653 # Done. set-psdebug –strict; # Require declaration of powershell variables # Set-PSDebug -Off; # Do not require declaration of variables $strPathToFile = "U:\Development"; $strFileName = "XMLDoc.old.txt"; $xmlLog = [xml]( Get-Content (join-path -path $strPathToFile $strFileName)); $colPublicFolders = $xmlLog.Public_Folders.Public_Folder; foreach ($objPublicFolder in $colPublicFolders) { # If there was only one replica for a folder, then # ($objPublicFolder.Replica -is [array]) would return false if ($objPublicFolder.Replica -is [array]) { $Item_Count_for_First_Replica = $objPublicFolder.Replica[0].Item_Count; $colReplicas = $objPublicFolder.Replica; $mismatch = $False; # Compare the item count for each replica against # the first replica item count. foreach ($objReplica in $colReplicas) { If ($objReplica.Item_Count -ne $Item_Count_for_First_Replica) { $mismatch = $True; } } if ($mismatch -eq $True) { Write-Host "Item Count mismatch for folder`n`t" $objPublicFolder.Path; foreach ($objReplica in $colReplicas) { Write-Host "`t" $objReplica.Server_Name ": " $objReplica.Item_Count;} } } $colReplicas = $Null; $Item_Count_for_First_Replica = $Null; $objReplica = $Null; } $strPathToFile = $Null $strFileName = $Null $objPublicFolder = $Null; $colPublicFolders = $Null; $xmlLog = $Null; Write-Host "Done.";
_____________________________
Microsoft Windows 2000 Scripting Guide - The best book for newbie scripters
http://www.myspace.com/Evil__Overlord
Post #: 1
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Windows PowerShell
>> HowTo: Reading / Searching through XML Files
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI