header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Search
Search Area
Criteria Options
Search Topics From
Search By User
Search in Forum(s)
Included Forums: ALL
Topic
Cluster - Reporting on multiple Applications on same node
I read some posts here, but didn't see anything that would point to what I need. Tried running basic MSCluster_ResourceGroup query, but it produced no results:Get-WMIObject MSCluster_ResourceGroup -namespace root\MSCluster -filter "name='SQL Server ...
by BikeBoy in General PowerShell on 05 May 2011 08:55 PM
RE: An empty pipe element is not allowed when writing to an output file
Thanks guys, DiffyRiot - looks like you need Get-Content -Path d:\computers.txt Otherwise I got an error: "Cannot execute a document in the middle of a pipeline" But it works, thanks Cruisader03 - tee-object instead of Out-File is nice, ...
by BikeBoy in General PowerShell on 04 Feb 2011 08:22 AM
An empty pipe element is not allowed when writing to an output file
Ok, what I want is to feed the script a computer list, then check path for specific file existance on each machine, and write results to Output.txt The following script is erroring out when I try to pipe out empty $i when path does not exist.An empt ...
by BikeBoy in General PowerShell on 31 Jan 2011 03:31 PM
RE: Example of IF with multiple conditions, like if (!$var3 and !$var4)
found my answer: -and if (!$var3 -and !$var4) { Do A} Thanks anyway
by BikeBoy in General PowerShell on 07 Dec 2010 12:42 PM
Example of IF with multiple conditions, like if (!$var3 and !$var4)
I need to test for both $var3 and $var4 variables in my IF statement, and am getting an error>if (!$var3 and !$var4) { Do A} else if (!$var4) { Do B} else { Do C }What is the proper syntax?Thanks
by BikeBoy in General PowerShell on 07 Dec 2010 12:01 PM
RE: how to specify parameter is NULL by default in Powershell
Thanks Bartek, I like the [CmdletBinding()] to make $Var1 mandatory, but since my script is kicked off by scheduling engine, it'll just sit there waiting for $var1 forever, so that's why I need to check for it manually, or exit. Just c ...
by BikeBoy in General PowerShell on 26 Nov 2010 01:17 PM
how to specify parameter is NULL by default in Powershell
Hi all,How can I easily specify that if the parameter is not passed, it should be NULL by default. So in this example $Var1 should always be passed, and I check for that. $Var2 most of the time WILL NOT be passed at all, and it's ok. Instead of doin ...
by BikeBoy in General PowerShell on 24 Nov 2010 12:09 PM
RE: Deleting old file and folders with remove-item -recurse option
Thanks -nolike works, like Where-Object -FilterScript { $_.FullName -notlike '*\Exception\*' } BTW, do you know how to equate pipeline variable to null?? I want to check if $_. is null, and if it's not do something, like so: if ($_. -ne $nul ...
by BikeBoy in General PowerShell on 27 Aug 2010 07:55 AM
RE: Deleting old file and folders with remove-item -recurse option
Thanks for your response, I got a bad arg error, does '*\Exception\*' need to be in double-quotes? PS C:\myscriptPath.ps Bad argument to operator '-match': parsing "*\Exception\*" - Quantifier {x,y} following nothing.. At C:\myscriptPath.ps 1:28 cha ...
by BikeBoy in General PowerShell on 26 Aug 2010 12:01 PM
RE: Deleting old file and folders with remove-item -recurse option
OptikGhost, here's another thought: Say there's one folder called "Exception" contents of which I don't want to delete. Can I still keep the same structure of the script, and accomplish that? I do something like this, but the contents of "Excepti ...
by BikeBoy in General PowerShell on 08 Aug 2010 09:52 PM
RE: Deleting old file and folders with remove-item -recurse option
works like a charm, I love Foreach-Object. The default formating is good, since it has the Mode ( file or folder), LastWriteTime Length, and Name . Thanks a bunchPS one quick question, is -Force param in Remove-Item -Force   needed in case the file ...
by BikeBoy in General PowerShell on 02 Aug 2010 12:00 PM
RE: Deleting old file and folders with remove-item -recurse option
0ptikGhost, That will work too. Actually I need to log the files that I am deleting, and I found that the best loging is as follows: # Create log file [string]$logFile = "\\MyUNCpath" "Deleting files on $targetFolder at $CurDate" | Out-File ...
by BikeBoy in General PowerShell on 29 Jul 2010 11:01 AM
RE: Deleting old file and folders with remove-item -recurse option
GWHowarth88, I think this is going to work out for me. I see what you did with the ForEach-Object function, so I can work with it. Thank you very much, this is a good way to learn PS
by BikeBoy in General PowerShell on 23 Jul 2010 11:02 AM
RE: Deleting old file and folders with remove-item -recurse option
actually it worked when I added another -Recurse here: but still deleted a whole folder when I had a new file in the old folder. my goal is to leave a file if it's new, and just delete a folder. if (Test-Path -Path $targetFolder) { ...
by BikeBoy in General PowerShell on 23 Jul 2010 10:55 AM
RE: Deleting old file and folders with remove-item -recurse option
That one just skips all the folders and files, did not delete anything
by BikeBoy in General PowerShell on 23 Jul 2010 10:27 AM
RE: Deleting old file and folders with remove-item -recurse option
That's good, and thanks for your response. i added -recurse to Remove-Item ...but the problem still is that if there's an old folder, it gets deleted even though it has new files in it. So when the script sees Folder older than 30 days it wac ...
by BikeBoy in General PowerShell on 22 Jul 2010 11:09 AM
Deleting old file and folders with remove-item -recurse option
I have the following script to delete the old files/folders on a share. I need to keep files that were created earlier than 30 days.$LastWrite seems to look at Date Created, and not Date Modified.Problem is whenever there are folders that where crea ...
by BikeBoy in General PowerShell on 22 Jul 2010 07:30 AM
RE: running PS script remotely
yes, so I have a script that calls the SQL procedure to back up sql databases through Sqlcmd. I executed it just fine manually from the 64bit shell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe It just seems that things that work in ...
by BikeBoy in General PowerShell on 09 Feb 2010 11:22 AM
RE: running PS script remotely
another starnge thing I am expiencing is it looks like 2 shells are not the same: 32bit in C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe doesn't understand TrimEnd method I get [System.Object[]] doesn't contain a m ...
by BikeBoy in General PowerShell on 09 Feb 2010 10:34 AM
RE: running PS script remotely
I think I should be able to specify to run the powershell from C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe instead of C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe , correct? invoke ot like so: C:\Windows\System32\Wind ...
by BikeBoy in General PowerShell on 09 Feb 2010 07:41 AM
RE: running PS script remotely
Marco, it is x64 bit, do you mean in the PowerShell.exe on C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe ?
by BikeBoy in General PowerShell on 09 Feb 2010 06:42 AM
running PS script remotely
Hi all,I need to execute PowerShell script on a server via command from a remote server running CA7 job. The ExecutionPolicy is set to RemoteSigned and I can execute script locally just fine, but when I try executing with CA7 job I get this error: F ...
by BikeBoy in General PowerShell on 08 Feb 2010 02:26 PM
RE: How to output a log file to a remote server via Out-File -filepath
Nope, I tried that. I build my path based on cancatination of instance name and previous variable $Path1 that I get initially in the same script, like so: [string]$MyPath="\\" + $Servername + "\" + $Path1.value.Replace(":\","$\") + "DBBackup ...
by BikeBoy in General PowerShell on 07 Jan 2010 12:24 PM
How to output a log file to a remote server via Out-File -filepath
I am using Invoke-Sqlcmd from SQLPS to execute a stored proc, and want to output a log to a path on the remote server that I get earlier in my script.So first I get the path by querying a table, and capture it in a $Path variable:$Path=Invoke-Sqlcmd ...
by BikeBoy in General PowerShell on 04 Jan 2010 07:51 AM
can Powershell script be called from standard Windows command prompt ?
Is it possible to execute PS script from regular cmd prompt ? I mean not the Powershell command prompt but old Windows command prompt.
by BikeBoy in General PowerShell on 04 Jan 2010 07:21 AM
Active Forums 4.3
right
footer   footer
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer   footer