At the very least don't use Add-Content inside the loop like that. You should open all the output files before the loop and keep them open throughout.
|
|
# ¿ Aug 21, 2018 23:27 |
|
|
# ¿ May 14, 2024 03:55 |
He has one "master" workbook that references data in the other workbooks via the INDIRECT function, and to let those formulas recalculate with newest data, he has to open those workbooks too.
|
|
# ¿ Aug 25, 2018 04:17 |
PBS posted:What's the purpose of leaving them open then? I'm guessing you need to click the "recalculate" button in Excel to actually make it do the update.
|
|
# ¿ Aug 25, 2018 15:01 |
Does anyone know of a PS module or method for reading/querying/updating SharePoint lists? The idea being to write tools in PS that fetch some data and store in a SharePoint list for a web-based lookup tool to use.
|
|
# ¿ Sep 12, 2018 10:30 |
SharePoint Server (2010 because upgrading is unnecessary busywork)
|
|
# ¿ Sep 12, 2018 14:22 |
The Fool posted:Use the CSOM slartibartfast posted:Take a look at SPReplicator. Thanks, these look great.
|
|
# ¿ Sep 13, 2018 08:05 |
Do you need to get this for every user and group object in AD? In that case just use Get-ADObject to return all user and group objects under the relevant OU. Or even just globally. Sort and filter the results afterwards. Remember to use the -Properties parameter to specify which properties to fetch the values for. E:f,b
|
|
# ¿ Oct 4, 2018 18:03 |
Wouldn't this work?code:
nielsm fucked around with this message at 20:15 on Nov 29, 2018 |
|
# ¿ Nov 29, 2018 20:13 |
Submarine Sandpaper posted:What's the best way to terminate a script not using throw or exit? Restart-Computer
|
|
# ¿ Nov 30, 2018 23:22 |
Agrikk posted:Format-List -Property "Name" code:
code:
code:
|
|
# ¿ Dec 31, 2018 08:51 |
ForEach-Object is a replacement for writing a one-off filter function to insert in a pipeline. foreach statement is a way to repeat a block of statements not connected to a pipeline as such. In my day -to-day use, ForEach-Object is more useful most of the time.
|
|
# ¿ Mar 25, 2019 20:04 |
Instead of $foo | % {$_.Trim()} you can simply write $foo | % Trim. Since Powershell 3 ForEach-Object can take the name of a member property or function and will just extract (or call) that on each object. If you don't need the verbose output you can do just this: code:
|
|
# ¿ Apr 23, 2019 17:55 |
Wizard of the Deep posted:If you're trying to pass by pipeline, I think you should be using "Get-AzureADUser". Yeah, if it's at all similar to Set-ADUser then Set-AzureADUser does not return anything, unless you also give it the -PassThru flag. If you aren't actually setting anything you should just use Get-AzureADUser instead.
|
|
# ¿ Jul 31, 2019 14:25 |
This is not strictly a PowerShell question, but I suspect the regulars here tend to have experience with working with AD programmatically... The UserAccountControl field on AD accounts has two flags that seem to never be set: LOCKOUT and PASSWORD_EXPIRED Did they only get set by older versions of AD or even NTDS? If new versions don't set these flags, what's the best way to detect these states?
|
|
# ¿ Aug 15, 2019 08:02 |
Ah that computed field is probably what I want then. I'm not actually working in PowerShell for this, but rather using the System.DirectoryServices API from .NET in a C# desktop application, and later after making my previous post discovered that to use the msDS computed properties you have to explicitly request them. Requesting "all properties" in particular does not return them.
|
|
# ¿ Aug 15, 2019 16:30 |
Pipe to Measure-Object to count zero, one, and many objects correctly.
|
|
# ¿ Aug 16, 2019 06:44 |
Toast Museum posted:I haven't played with that field myself, but it looks like a somewhat newer field is ms-DS-User-Account-Control-Computed, though that page doesn't indicate implementation beyond 2012, and I'm not sure what has superseded it. Yeah definitely. These Computed properties are neat but you need to know they are available and only exist when you request them explicitly. code:
C# code:
nielsm fucked around with this message at 09:30 on Aug 16, 2019 |
|
# ¿ Aug 16, 2019 09:27 |
That looks very much like a "try again later" type error yes. Just handle it and reschedule the job, probably have a limit on number of retries.
|
|
# ¿ Aug 21, 2019 17:06 |
The odd thing about the ActiveDirectory module is that it uses a webservice instead of straight LDAP. We definitely have AD servers (running a separate domain) I can manage via the AD Users and Computers MMC-snapin, but can't access via the ActiveDirectory module in PowerShell.
|
|
# ¿ Aug 29, 2019 17:40 |
Is this going to run on a client machine through an interactive login? If it is, maybe just use Automation. Basically $outlook = New-Object -ComObject Outlook.Application and go from there.
|
|
# ¿ Oct 3, 2019 16:42 |
Toast Museum posted:If you need to send keystrokes, Write-Host won't get the job done. It sounds like [System.Windows.Forms.SendKeys]::SendWait(string) might work here, though. The documentation for SendKeys.Send shows how to send special characters. As far as identifying when you've reached the end, I'm not sure, since it sounds like there's nothing returned for PowerShell to look out for. Those functions are only for faking keyboard input to other local GUI applications. They're most likely not suited for controlling an SSH session, especially not one you connected to via PS. It might sort-of work if you used PuTTY or another not-windows-builtin-console application, but then you'd still have the SSH connection pop up on a separate window, and need to figure out a way to read back the contents. What you want to do is start the ssh process and connects its stdin and stdout to pipes, then read and write from those.
|
|
# ¿ Oct 31, 2019 00:16 |
If it's just a one-shot task, I'd reach for a text editor with multi-file search replace.
|
|
# ¿ Nov 1, 2019 23:31 |
Depends on the Exchange version, really. As far as I understand the extended AD permission is what Exchange 2007 did, and some update to 2013 changed it to be a MailboxPermission, while still accepting the AD permission. But O365 is always the RecipientPermission.
|
|
# ¿ Jul 10, 2020 20:37 |
I'm writing a script module to wrap a web service. Some parts of the web service don't have great lookup features yet, so to find an object by e.g. display name I have to fetch all objects of the class and then filter them myself. I have something like this: code:
But when I try the ByName or ByFrob parameter set I get nothing back. Fake edit: I found the answer while writing this post, so leaving it here so anyone else can maybe learn too. The issue is that Invoke-RestMethod technically returns a object[] array instead of a PowerShell collection or PSCustomObject, when the web service call returns a JSON array. You need to do "something" to the result to force it to convert into a regular PowerShell collection of PSCustomObject data. One thing you can do is simply wrap the call in parentheses, like this: code:
By the way this is on PowerShell 5.1.17763.1007 on Windows 10 1809. Maybe it's fixed/improved in the newer versions.
|
|
# ¿ Aug 7, 2020 12:39 |
Toshimo posted:Ok, I've been basking my face into this for hours, and I'm trying to do a registry import "the PowerShell way" using New-ItemProperty, and it's all fine and normal until I try to make a Binary value. This works for me: code:
|
|
# ¿ Jun 23, 2021 21:16 |
First, check what's going on with your copy-paste. All the line breaks are double on the forums, and the indentation looks uneven, especially in the documentation block. (Also, 16 spaces indentation is weird too.) As far as I can tell from reading the code, if you send in services by the pipeline, they're going to be processed sequentially with waiting for the timeout for each individual service. It would run the timeouts in parallel only if you passed the services as an array in a single parameter. If your intention is to process the timeout for all the service stopping in parallel then you'd have to only start those jobs in the Process{} block, and then do all the remaining work in the End{} block, which runs after the pipeline input to the cmdlet has finished. The basics of CmdletBinding and functions with Process{} that take input from the pipeline, is that the Process{} block is an implicit loop over each object on the pipeline, so treat it as that. The exception to that is if the type of the pipeline parameter allows array types and you pass the input object as an array as a parameter instead of through pipeline, then the Process{} block runs once with the array as input, and in that case you'd have to do an internal foreach loop over that. So what I want to say is, if you want to allow passing an array of services as a parameter and have it work, then keep the foreach loop inside the Process{} block too. Your return values are odd. The best way to return objects to the pipeline is actually to not use the return statement but just leave them to output. Additionally, you should normally not return a hashtable, but use the [PSCustomObject] pattern to convert hashtables to objects that behave nicer and work with the standard formatting and output cmdlets. Consider the standard PowerShell function naming scheme, "Verb-Noun". Stuffing extra terms in front of the verb is bad practice. PowerShell code:
It's often a good idea to try to structure data all the way through, including returns, rather than formatting for text display only.
|
|
# ¿ Jun 8, 2022 21:29 |
I'm working on a module to provide an interface for calling a webservice and do batch changes to some data. However, this webservice has some annoying rate limits, but does support batching multiple operations into a single request. So if I can batch my changes, I can work through any data much faster. Do anyone know of tools or techniques to split a pipeline of individual objects in PowerShell into blocks of some size, say 20 or 100 objects per block, and then process them per block instead of individually?
|
|
# ¿ Mar 7, 2023 10:35 |
Yes if you can, connecting to MS SQL Server with Integrated Authentication is often the easiest and most secure. Then you just need your process to run under the appropriate user token, such as a service or batch job account, or you can use Run As to start as another user.
|
|
# ¿ Apr 22, 2023 09:05 |
|
|
# ¿ May 14, 2024 03:55 |
I'm not sure I understand, do you mean like an array of arrays?code:
Since I assume you've already tried ConvertTo-Json directly on your data and decided that it will not work.
|
|
# ¿ Jul 5, 2023 21:15 |