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
RE: Can this script generate a log file?
Posted By Rick on 30 Apr 2012 11:16 AM I got that to work, and should work for my needs. However, the text file seems to look like a long run on sentence. Is there a way to get each process to show up as a new line? Your text editor doesn't kn ...
by 0ptikGhost in General PowerShell on 04 May 2012 03:38 PM
RE: Help with objects
Does this not work? $TestArray = @() for ($i = 0 ; $i -lt 3 ; $i++) { $TestArray += New-Object PSObject -Property @{ Username = "User$i" ComputerName = "Computer$i" IPaddress = $null } } $InputArray = @( ...
by 0ptikGhost in General PowerShell on 04 May 2012 03:19 PM
RE: Accessing Stored Credentials
The ConvertTo-SecureString and ConvertFrom-SecureString cmdlets work with a given account and machine. Imagine the following scenario: 2 machines (ServerA and ServerB) and 2 accounts (Account1 and Account2). I'm going to use account@machine to desig ...
by 0ptikGhost in General PowerShell on 04 May 2012 10:32 AM
RE: Problem with colors
I have experienced something similar when working in the PowerShell ISE. I have seen messages written with the correct color and later on changing to a single color.I have never seen this behavior in the PowerShell console.
by 0ptikGhost in General PowerShell on 04 May 2012 10:14 AM
RE: Passing objects to PowerShell scripts
I don't think you need to use [ref]. Just remove [ref] everywhere you are currently using it.
by 0ptikGhost in General PowerShell on 20 Apr 2012 08:39 AM
RE: Save notepad file
Thanks EBGreen! Learn something new every day!
by 0ptikGhost in General PowerShell on 20 Apr 2012 08:07 AM
RE: Import-Csv and set the value in the variables
Just use a loop:foreach ($Item in @(Import-Csv -Path 'C:\Alt Temp.csv' -Delimeter ';')) {    $Login = $Item.Login    $Template = $Item.Template    # Rest of code as normal}Of course, you could simply replace every use of $Login with $Item.Login and ...
by 0ptikGhost in General PowerShell on 19 Apr 2012 10:37 AM
RE: Save notepad file
You don't need to use notepad to write stuff to a file. Take a look at the Set-Content, Out-File, and Tee-Object cmdlets. You could also use output redirection (see help about_redirection) to send stuff to a file.To create a new empty file (no conte ...
by 0ptikGhost in General PowerShell on 19 Apr 2012 10:30 AM
RE: Issue with Custom PSObject with dynamics columns
Thank you. You are allowing powershell to wrap up the objects back into psobjects when you "return" the array you construct inside the function. PowerShell doesn't actually return the array. It enumerates the array sending each object through the ...
by 0ptikGhost in General PowerShell on 19 Apr 2012 09:11 AM
RE: Issue with Custom PSObject with dynamics columns
Please just copy/paste the exact function and how you invoked it?
by 0ptikGhost in General PowerShell on 18 Apr 2012 09:33 AM
RE: Issue with Custom PSObject with dynamics columns
I meant can you show how you used my suggested solutions? You said they didn't work.
by 0ptikGhost in General PowerShell on 18 Apr 2012 09:01 AM
RE: Remoting and Code Reuse
Posted By Chris on 18 Apr 2012 07:18 AM 4. Finally my last thought is to forget about code reuse and don't modularize anything. Just build all functions and calls into my scripts as required. This is my least favorite idea, but would probably get me ...
by 0ptikGhost in General PowerShell on 18 Apr 2012 09:00 AM
RE: Issue with Custom PSObject with dynamics columns
I don't have forests to try this out with...Please send the exact code you are executing. The contents of the script and how you are invoking the script and how you are executing the command directly on the command line. The specifics count. Your de ...
by 0ptikGhost in General PowerShell on 18 Apr 2012 08:39 AM
RE: Issue with Custom PSObject with dynamics columns
It appears the problem is related to how powershell wraps all objects in psobjects implicitly but doesn't always unwrap them when they are passed around. Try this: $Forests = 'test.local', 'test2.local' $Domains = @( $Forests | ForEach-O ...
by 0ptikGhost in General PowerShell on 17 Apr 2012 01:03 PM
RE: Issue with Custom PSObject with dynamics columns
Can you post the code you executed? I can't reproduce your setup here so I don't know what objects you are actually getting.
by 0ptikGhost in General PowerShell on 17 Apr 2012 12:47 PM
RE: AD Password Expires Script
Run the following to make sure the objects have all the properties you expect (like pwdLastSet): Get-QADUser -Enabled -PasswordNeverExpires:$false -SizeLimit 0 -Email * | Add-Member -PassThru -MemberType ScriptProperty -Name Expires -Value { $Max ...
by 0ptikGhost in Active Directory on 17 Apr 2012 12:45 PM
RE: AD Password Expires Script
Altered version of your First Script: Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue $MaxPassAge = (Get-QADObject (Get-QADRootDSE).defaultNamingContextDN).MaximumPasswordAge.days if($MaxPassAge -le 0) { thro ...
by 0ptikGhost in Active Directory on 17 Apr 2012 10:50 AM
RE: Issue with Custom PSObject with dynamics columns
$Forests = 'test.local', 'test2.local' $Domains = @( $Forests | ForEach-Object { New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('Forest', $_) } | ForEach-Object { [System.DirectoryServices.ActiveDirectory.Fores ...
by 0ptikGhost in General PowerShell on 17 Apr 2012 10:41 AM
RE: PowerShell Error
In particular, since the call to Substring() is generating an exception you are not getting any real output for that line. Suppressing is not likely to be the correct choice here. You need to decide what to do when the line is less than 8 characters ...
by 0ptikGhost in General PowerShell on 17 Apr 2012 10:27 AM
RE: Pad a zero in the Middle of a string
Posted By EBGreen on 17 Apr 2012 07:00 AM In my opinion, having many different ways to accomplish the same task is one hallmark of a good scripting language. Perl is one example of this and Pwershell has been heavily influenced by Perl. I realize t ...
by 0ptikGhost in General PowerShell on 17 Apr 2012 08:32 AM
RE: Pad a zero in the Middle of a string
If the file you are reading is different from the file you are writing then do this: $ReadFile = 'D:\TEMP\TodaysFile' Get-Content -Path $ReadFile\filetoreadfrom.tmp | ForEach-Object { $_.Insert(48, '0') } | Out-File -FilePath $ReadFile\filetooutp ...
by 0ptikGhost in General PowerShell on 16 Apr 2012 04:51 PM
RE: Problem handling <CR> with Write-Output
Try this (alternate form of the previous suggestion): foreach ($objResult in $colResults) { $objComputer = $objResult.Properties Write-Output "$($objComputer.name):$($objComputer.operatingsystem)" } If this doesn't work getting more of ...
by 0ptikGhost in General PowerShell on 13 Apr 2012 01:57 PM
HowTo: Use $VerbosePreference to control verbose messages from cmdlets and scripts
I'm trying to use $VerbosePreference to make all commands to write their verbose messages to the verbose stream. The about_Preference_Variables topic suggests that I should be able to set $VerbosePreference to Continue and all commands should write ...
by 0ptikGhost in General PowerShell on 13 Apr 2012 01:48 PM
RE: building arrays best practices
Posted By nbritton on 11 Apr 2012 10:35 AM I understand that there is a huge performance hit by using the following code when dealing with a lot of lines or members.  What would be the best way to build the array that would not take a performance h ...
by 0ptikGhost in General PowerShell on 12 Apr 2012 11:06 AM
RE: questions from a beginner
Jobs do not execute in the same directory where you issue the Start-Job call. You'll need to use an absolute path to your program-name. If you can't hard-code the path then you'll want to pass in the value using -ArgumentList.
by 0ptikGhost in General PowerShell on 12 Apr 2012 10:37 AM
RE: Catch Error
So if im correct, if an error occurs, it will say "An Error has Occured", but if an error does occur, i dont want it to wrote "Services on $server have been collected... how do i do it so that if an error does occur, it says "An error has occured" i ...
by 0ptikGhost in General PowerShell on 12 Apr 2012 10:34 AM
RE: Elevating Set-Acl
Posted By Geoff Guynn on 06 Apr 2012 06:23 PM I would write your elevated code into another script file and just execute the whole script with arguments. This misses the point. I have a large script that I could elevate in its entirety if I choo ...
by 0ptikGhost in General PowerShell on 07 Apr 2012 12:36 AM
RE: Hashtable problem
Cannot index into a null array. At C:\Users\Administrator.uk03lap0001\desktop\html.ps1:7 char:133 + return @( -split $WebClient.DownloadString($Url) | Where-Object { $_ -match '(/learn-chemistry[^"]*)"' } | ForEach-Object {$UrlHash[ T ...
by 0ptikGhost in General PowerShell on 06 Apr 2012 03:24 PM
RE: Cutom objects, hashtables and such
CSV is not a good way to store the data the way you want. You could create objects with MemberName and GroupName properties and then create a CSV file that looks like this: MemberName,GroupName James,Group1 Don,Group1 Carroll,Group1 Paul,Group1 ...
by 0ptikGhost in General PowerShell on 06 Apr 2012 03:11 PM
RE: questions from a beginner
I'll refer you to the about_Jobs and about_Job_Details help topics. You are going to want to wait only on the jobs you created so keep them around in an array.$Job = @()$Job += Start-Job -ScriptBlock { param ( $argument ) path\to\executable.exe $arg ...
by 0ptikGhost in General PowerShell on 06 Apr 2012 02:34 PM
Page 1 of 1312345 > >>
Active Forums 4.3
right
footer   footer
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
footer   footer