Friday, 15 June 2012

PowerShell: Set current item in foreach to an array -


Thanks for watching Thanks I want to loop through each item in a folder and the name of the merit for an array And want to add length (size) so that I can send an email. For example, if there are files without .txt extensions, then I do not want to include them. What happens is an email sent, but there is a list of the same files in several tables, I know the issue is how I am storing the current file in the array, but it is not certain how to fix it. . I just want to add the current file once.

Here is the code I have been stripped of:

  $ myFolder = "C: \ users \ myName \ document \ temporal" $ Receive count = 0 $ a = "& lt; Style & gt; BDI {font-family: verdana; font-size: 9pt;} "$ a = $ a +" body {background color: white;} "$ a = $ A +" table {border width: 1px ; Border-style: solid; border-color: black; boundary-fall: collapse;} "$ a = $ a +" TH {border-width: 2px; padding: 7px; border-style: solid; border-color: Black; background-color: light-weight, padding-right: 2px;} "$ a = $ a +" TD {border-width: 2px; padding: 5px; border-style: solid; border-color: black; background-color: white; padding-right: 2px;} "$ a = $ a +"  "foreign currency ($ myFolder $ File) {$ FileName = $ file.name Echo "Curator file: $ filename" if ($ filename- like "* .txt") {$ ReceiveContents + = 1 # This section I am doing wrong: $ files Reexpected + = @ (Object name, length | converto-html-$$ a)}} echo "found $ received files." If ($ FilesReceivedCount -gt 0) {# Send email ...}  

Try Do the following:

recover $ # files = @ () $ recover files $ = @ ($ file | select- object name, length) $ html = $ FilesReceived | If you use the GC parameter in this way, you can filter the file selection in advance:

Pre> Go - BalTime C: \ Path \ *. * -enclude * .txt

so that you can only handle .txt files


No comments:

Post a Comment