How to avoid print the garbage info in a Foreach loop?
i write ps script, print out supported logfile types.
$supportedlogfile=new-object system.collections.generic.list[string] $moc=get-wmiobject -class win32_nteventlogfile foreach($item in $moc) { if($item.logfilename -eq $logfilename) { $actualsize=$item.filesize/1024 break } $supportedlogfile.add($item.logfilename+"`r`n") } return $supportedlogfil applicationhardwareeventsinternet explorerkey management serviceoalertsoperations managersecuritysystemvm managerwindows powershell$item.logfilename$item.logfilename$item. logfilename$item.logfilename$item.logfilename$item.logfilename$item.logfilename$item.logfilename$item.logfilename$item.logfilenameapplication'r'nhardwareevents'r'ninternet explorer'r'nkey management service'r'noalerts'r'noperations manager'r'nsecurity'r'nsystem'r'nvm manager'r'nwindows powershell'r'napplication'r'nhardwareevents'r'ninternet explorer'r'nkey management service'r'noalerts'r'noperations manager'r'nsecurity'r'nsystem'r'nvm manager'r'nwindows powershell'r'napplication hardwareevents internet explorer key management service oalerts operations manager security system vm manager windows powershell
here got 2 problems:
1. 'break' in foreach loop seemed didn't work
2 how avoid print garbage infos? need just
hardwareevents
internet explorer
key management service
oalerts
operations manager
security
system
vm manager
windows powershell
thanks, eric
ps > get-eventlog -list | select -exp log application dfs replication hardwareevents internet explorer key management service media center oalerts security system windows powershell
Windows Server > Windows PowerShell
Comments
Post a Comment