Reply To: Runs fine in the ISE but not when ran as a script?
So… What’s it do? Error messages? Different behavior? We can’t easily run your script so understanding what’s happening would be useful in helping you.
View ArticleReply To: Runs fine in the ISE but not when ran as a script?
nothing no errors nothing it just completes. when I high light portions and run in the ISE works fine. connects to sql grabs query and exports data to csv and uploads. when ran a scheduled task, or...
View ArticleReply To: Runs fine in the ISE but not when ran as a script?
it just returns back to the prompt no erros
View ArticleReply To: Setting up DSC on Win2008R2 Server Can't find DSC-Service Feature
I have checked my 2008R2 machine also and while I find all the cmd-lets relating to DSC and can interrogate the DSC local configuration manager I do not find anything relating to DSC service. Perhaps...
View ArticleReply To: Runs fine in the ISE but not when ran as a script?
That would be because you have if(!(Test-Path -Path $OutputDir)) {mkdir $OutputDir} else {continue} Continue starts a new iteration of the current loop. An if statement is not a loop, so in your case,...
View ArticleReply To: Setting up DSC on Win2008R2 Server Can't find DSC-Service Feature
I thought I remembered reading somewhere that the pull server had to be Server 2012. I’ll see if I can find that reference. Edit: I might be remembering wrong. Everything I’ve found tonight says that...
View ArticleReply To: Confused about -or behavior in an If/Then construct
The -or operator is a binary operation that “adds together” the value of the statements you’re testing, which means only one statement needs to be $true before it continues (1 + 0 is 1). The -and...
View ArticleMoving, renaming & copying folder trees
I have a scenario where we want to roll back certain folders on a drive that contain a common text file while preserving the folders & sub folders that contain those test files by moving them to a...
View ArticleReply To: Moving, renaming & copying folder trees
You have a bunch of basic steps there: Get-ChildItem to identify the folders that you want to target (probably by looking for this text file you mentioned), and some combination of Move-Item,...
View ArticleReply To: Setting up DSC on Win2008R2 Server Can't find DSC-Service Feature
OK, I’ve deleted my previous posts where I was fumbling around with this. I’ve just rebuilt my 2008 R2 SP1 VM from scratch to test the process, and it appears to work: - Install Windows Server 2008 R2...
View ArticleReply To: Setting up DSC on Win2008R2 Server Can't find DSC-Service Feature
Dave, That’s brilliant. It’s actually Sat evening here now (in NZ), so I’ll give this a go on Mon morning when I get back into work. I got up to the dism command to enable the DSC-Service, but didn’t...
View ArticleFile search – multiple remote servers – specific file types?
Hello, I’m trying to find out how to write a script that will search a list of servers in a text file for specific file types, then report into a CSV file with attributes that are: size, last access...
View ArticleIs there a better way to expand a calculated field?
I can do this but using Select-Object twice like this is ugly and probably inefficient. Is it possible to do an -ExpandProperty or equivalent on a calculated property? Get-Wmiobject -Class...
View ArticleReply To: Is there a better way to expand a calculated field?
You could just use ForEach-Object instead: Get-Wmiobject -Class Win32_LogicalDisk | ForEach-Object { $_.DeviceID.TrimEnd(':') }
View ArticleReply To: File search – multiple remote servers – specific file...
That type of thing would be very slow over the network. Ideally, you’d have PSRemoting enabled on all of the servers, and could have them run a local search via Invoke-Command. Even then, though,...
View ArticleReply To: Is there a better way to expand a calculated field?
Not sure why you need the second select as £> Get-Wmiobject -Class Win32_LogicalDisk | Select @{n=’Drive’;e={$_.DeviceID.TrimEnd(‘:’)}} Drive —– C D E F If you just want the drive letters then go...
View ArticleReply To: Is there a better way to expand a calculated field?
@Richard – I am wanting an output as an array of strings and not an array of objects. This is just academic tinkering mostly and figuring out how I can write this in the shortest way possible yet...
View ArticleReply To: Is there a better way to expand a calculated field?
Depends on whether you intend to support PowerShell 2.0 or not. The (Get-Wmiobject -Class CIM_DataFile | Select -first 20000).DeviceID.TrimEnd(‘:’) syntax requires version 3.0 or later.
View ArticleReply To: Is there a better way to expand a calculated field?
It will always be at least v3.
View ArticleReply To: Is there a better way to expand a calculated field?
Thanks guys. I appreciate the help.
View Article