Quantcast
Channel: PowerShell.org » All Posts
Browsing all 13067 articles
Browse latest View live

Reply To: PowerShell & Robocopy

How do i make PowerShell recognize that $username in the text file (excludeddirs.txt) is a variable and not a string? ——————————————————————————- ROBOCOPY :: Robust File Copy for Windows...

View Article


I don't understand this behavior

In a module, I have the following function snippet: function Get-InstalledSoftware {   [CmdletBinding()] param ( [string[]]$Name, [string[]]$Publisher, [string[]]$Computername = 'localhost' ) begin {...

View Article


Reply To: I don't understand this behavior

It looks like it has to do with your $Name parameter being a string array, while in the assignment of the $Operator variable it's being treated as a string. If I change the param block to...

View Article

Reply To: PowerShell & Robocopy

Get-Content won't perform variable expansion, so you could try something like this: $excludedFiles = gc .\excludedfiles.txt | % { $_ -replace '\$Username', "$username"}

View Article

Reply To: are begin block variables not global?

<# .Synopsis Compresses IIS logs based on provided age in days .DESCRIPTION Creates ZIP Archives in the default IIS log file path with a date code based on log file age adds those logs to the ZIP...

View Article


Reply To: are begin block variables not global?

I don't see any problem with the scope of the $tempFolder variable. It should be usable right to the end of the function. It is a little bit odd that you have $LogFileDays listed as able to be passed...

View Article

Image may be NSFW.
Clik here to view.

Reply To: I don't understand this behavior

Yep, that was it. Thanks! Amazing how a couple of characters can screw you up.

View Article

Reply To: are begin block variables not global?

Thank you for catching the ValueFromPipelineByPropertyName param property I forgot to clean that up after using the Ctrl+J Snippet. I will just clean that up rather than handle errors for it because...

View Article


Reply To: GUI "Defaults" vs "Properties"

That is what is happening, changing the defaults does not change my pinned Powershell shortcut. Hitting the Start button, and typing powershell also accesses a shortcut, it isn't changed by "defaults"...

View Article


Reply To: I don't understand this behavior

At least it didn't cost you millions....

View Article

Reply To: I don't understand this behavior

Ha, good point!

View Article

Reply To: PowerShell & Robocopy

I was able to get it working by replacing the $username within excludeddirs.txt to "zzz" and then replacing the "zzz" with $env:USERNAME after calling Get-Content '\The BUS\excludeddirs.txt'...

View Article

Get-ADUser -Filter string array

Just trying to simply get the Filter param for Get-ADUser to accept an array of strings for input but having a difficult time at it. Not familiar with tackling with arrays on Powershell. I figured...

View Article


Reply To: Get-ADUser -Filter string array

The -Filter param on each cmdlet uses that cmdlet's provider to filter results vs. using something like -Include or Where-Object. You could get this done via Where-Object but I don't recommend it...

View Article

Reply To: Get-ADUser -Filter string array

See the help file: -filter <string> -Filter doesn't accept an array. PowerShell is turning the array into a single-string delimited list, which is why it doesn't work. You've got to run the...

View Article


Reply To: Compliance server TargetName is IP address

I just ended up doing this in my output to translate the IP address to Hostname: ([System.Net.Dns]::gethostentry($_.TargetName)).HostName

View Article

Reply To: Using dsc – how can you deploy files related to existing...

Why not do the file copy in two steps, with the service restart depending on the first? Configuration MyApp { node ServerA { File CopyFilesFromSharetoStaging { SourcePath = "\\FileServer1\Files"...

View Article


Using DSC Pull server to configure a new pull server

Hello, I'm trying to use the xPSDesiredStateConfiguration resource to configure a new pull server. Here is the set up: Current pull server set up at:...

View Article

Reply To: Using DSC Pull server to configure a new pull server

When you configured the current Pull server, where did you set the ModulePath to? That is where the xPSDesiredStateConfiguration Resource needs to live. The Resource also needs to be named like...

View Article

Reply To: Using DSC Pull server to configure a new pull server

Here is my ModulePath: ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules" I have zipped up the folder and called it xPSDesiredStateConfiguration_v.3.0.0.0.zip. Then I ran:...

View Article
Browsing all 13067 articles
Browse latest View live