I didn't find out-file yet, is there a nice location w/ good documentation on
these, (are these the cmdlets being referred to?) cmdlets?
So out-file will append to my log file for me then? I had been researching
using the [system.io.file] .net object to do that since I wasn't having luck.
Sounds like i was doing it wrong though...
I guess I should now ask for a good place to find documentation on the built
in commands like this one, before I waste time trying to re-write the
powershell (or wheel).
Thanks Rich
"RichS" wrote:
> new-item can be used to add data to a file as its created but isn't used once
> the file exists.
>
> As you are using a text file for your log you could use out-file (with the
> -append parameter specified) or a re-direction operator >> to send data to
> the file
> --
> Richard Siddaway
>
> Please note that all scripts are supplied "as is" and with no warranty
>
>
> "redi311" wrote:
>
> > It might help if i posted the script code eh?
> >
> > Anyway here it is.
> >
> > $scriptTitle = "GetSrvInfo v3.0"
> > $strSrv = "."
> > $compSysClass = "Win32_ComputerSystem"
> > $wmiNameSpace = "root\CIMV2"
> > # Gather Computer System Class configuration such as hostname, memory
> > installed, and domain name.
> > # Utilize Win32_computerSystem WMI Class to gather information
> > $colCompSysClass = Get-WmiObject -class $compSysClass -namespace
> > $wmiNameSpace -computername $strSrv
> > foreach ($objItem in $colCompSysClass)
> > {
> > $strDomain = $objItem.Domain
> > $strPC = $objItem.Name
> > $strPhysMem = $objItem.TotalPhysicalMemory/1024/1024
> > }
> >
> >
> > #File System operations for our log file.
> > $logDirPath = "C:\SCRIPT.LOG"
> > $logDirExists = Test-Path $logDirPath
> > $logFilePath = "C:\SCRIPT.LOG\" + $strPC + "_WMI_Info.log"
> >
> >
> >
> > # Write-Host $logDirExists
> > if ($logDirExists -eq "True")
> > {Write-Host "Log Folder found"
> > $logFileExists = Test-Path $logFilePath
> > if ($logFileExists -eq "True")
> > {Write-Host "Found Log File"}
> > else
> > {Write-Host "Creating Log File"
> > New-Item $logFilePath -type File
> > }
> > }
> > else
> > {Write-Host "Creating Log Folder"
> > New-Item $logDirPath -type directory
> > New-Item $logFilePath -type file
> > }
> >
> >
> > #Log the memory and host naming data to the log file.
> > $strPC = $strPC + "." + $strDomain
> > Write-Host "Host Name : " $strPC
> > Write-Host "Physical Memory Installed : " $strPhysMem "Mb"
> > Write-Host "Host Domain Name : " $strDomain
> >
> >
> > New-Item $logFilePath -type file -force -value "********************** Host
> > Network Name Settings ******************************"
> > New-Item $logFilePath -type file -force -value "Host Name : " + $strPC
> > New-Item $logFilePath -type file -force -value "Host Domain Name : " +
> > $strDomain
> > New-Item $logFilePath -type file -force -value "Physical Memory Installed :
> > " + $strPhysMem + "MB"
> >
> > Thanks!!
> >
> >
> >
> >
> > "redi311" wrote:
> >
> > > I'm fairly experienced w/ vbscript, but I'm having difficulty on my first
> > > attempts at converting some of my older vbscripts. I was hoping there might
> > > be someone kind enough to help me out by telling me what I'm doing wrong on
> > > this script.
> > >
> > > Seems to work ok until i try to use net-item to write lines into my log file
> > > that I creeate. When I do this it doesn't concatenate the string properly.
> > > Is this something I'm doing wrong? can someone help me out?
> > >
> > > Thanks!!
> > >
> > >


