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 ArticleI 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 ArticleReply 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 ArticleReply 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 ArticleReply 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 ArticleReply 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 ArticleReply To: I don't understand this behavior
Yep, that was it. Thanks! Amazing how a couple of characters can screw you up.
View ArticleReply 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 ArticleReply 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 ArticleReply 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 ArticleGet-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 ArticleReply 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 ArticleReply 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 ArticleReply 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 ArticleReply 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 ArticleUsing 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 ArticleReply 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 ArticleReply 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