- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
We just upgraded our Exchange testing environment from 2008 to 2008 R2, and none of the NLB/MSCS cmdlets seem to be installed. Any ideas?
|
#
¿
Sep 7, 2010 13:20
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 29, 2024 04:08
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Nevermind what a loving task it was to get powershell to even search. And nevermind how impossible Microsoft has made it to actually get the AD cmdlets. Why in the hell would I have to run a special instance of Powershell (Active Directory Module for Windows PowerShell) to actually be able to query AD. Shouldn't running Powershell on the DC be enough?
Import-Module ActiveDirectory
FISHMANPET posted:So I say to myself, this sounds perfect for Powershell! Except Powershell can't read the profile paths out of most of my accounts, they just show up as null. dsget works just fine, and looking at them in AD Users & Computers I see the bad profile path, but get-aduser shows nothing.
Get-ADUser -Filter * -Properties profilePath | Where-Object { $_.ProfilePath -match '\\server2' }
|
#
¿
Aug 16, 2012 12:35
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
:facepalm:
So for the long time was trying to get a powershell script that (simply) let me know if the current day was the first weekday of the month. For mailing purposes I send an email based on whether or not that is true
code:$currentday = get-date
$weekdays = "Monday","Tuesday","Wednesday","Thursday","Friday"
$months = 1..12
$firstofmonth = foreach ($month in $months) {1..7| %{get-date -month $month -day $_} | ?{$weekdays -contains $_.dayofweek}|select -first 1}
Function Firstday {
If ($firstofmonth -contains $currentday)
{write-host "First weekday of the month"}
Else
{Write-Host "Not the first weekday of the month"}
}
Firstday
FINALLY I was able to do it. I love/hate Powershell
You don't really need to do any date manipulation besides getting the day of the week and the day of the month. If you stop to consider what you're actually trying to find out, there are only two conditions that satisfy the test for "this is the first weekday of the month":
- It's the 1st of the month and it's a weekday
- It's the 2nd or 3rd of the month and it's Monday
So you can cut it down to this:
code:$date = Get-Date
$day = $date.Day
$dow = $date.DayOfWeek
if (($day -eq 1 -and $dow -ne "Saturday" -and $dow -ne "Sunday") -or (($day -eq 2 -or $day -eq 3) -and $dow -eq "Monday")) {
Write-Host "First weekday of month"
} else {
Write-Host "Not first weekday of month"
}
Vulture Culture fucked around with this message at 00:15 on Sep 6, 2012
|
#
¿
Sep 6, 2012 00:10
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
How easy is it to create a web frontend for powershell scripts? For instance a user creation script with a dropdown box to select department.
Work on the basics before getting too far ahead of yourself or you're gonna have a bad time. (Also, whoever has to maintain this poo poo once you leave is gonna hate you beyond belief.)
|
#
¿
Apr 16, 2013 14:40
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
I love PowerShell. It took me a while to wrap my head around it (as opposed to a more traditional scripting language), but now that I have I think it's about my favorite scripting language. It's also really nice to have an interactive .NET environment when you're writing C# or something and want to test something out.
That said, a lot of PowerShell stuff talks about how great it is because you can start out with a simple script and expand it into a full-blown thing without having to switch languages. Where are all these big PowerShell projects? I'm curious to see something that goes beyond a single script into being a real, full-scale PowerShell project, if they're out there.
http://chocolatey.org/
|
#
¿
Jul 2, 2013 13:28
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Has anyone tried out the idempotent Desired State Configuration stuff in PS 4.0 yet? If the given types do enough things, it seems like a really plausible alternative to Puppet/Chef/SCCM for Windows systems management.
|
#
¿
Oct 19, 2013 00:42
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Very simple script here. It works on one machine but not another. On the machine it doesn't work on, a command window comes up for a brief second showing some error that I can't read and then closes. When I run the script via the ISE however it works perfectly so I have no idea how to capture the error. Anyone know what the issue could be?
Here's the script-
$user = Read-Host "Enter the AD Account you wish to target"
$newpwd = Read-Host "Enter the new password" -AsSecureString
Set-ADAccountPassword $user -NewPassword $newpwd –Reset
Guesswork is sloppy debugging. Instead of double-clicking the script, start a persistent powershell.exe or cmd.exe window, then run the script from there so you can see the error it's kicking back.
That said, it's probably the execution policy.
|
#
¿
Dec 29, 2014 20:23
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
It's unlikely you'll be able to directly use the \\?\ prefix within PowerShell since PowerShell relies on the .Net objects behind the scenes.
There's a janky workaround that might work but you would have to run the script on the file server itself (you can't use UNC paths for this).
Basically, you could create directory junctions that are short, but lead into the deep paths. It would be a bit of a pain in the rear end, since you would constantly have to be using the junction path to traverse the share, and create new junction paths deeper inside as needed.
To create the junctions, you can use mklink, which does support the \\?\ prefix:
code:mklink /J "C:\mnt\Test" "\\?\Z:\v\e\r\y\long\path\name\here\to\folder"
To call that from powershell:
code:cmd.exe /c mklink /J "C:\mnt\Test" "\\?\Z:\v\e\r\y\long\path\name\here\to\folder"
Since the junctioning happens at the filesystem level, the Win32 APIs (the source of the problem) should not be able to tell that the shortened path is not the real path (their normalization techniques won't resolve this type of link).
It's really just the logistics of creating and deleting the junctions as needed that will be really annoying.
To delete, use rmdir (or rd):
code:cmd.exe /c rd "C:\mnt\Test"
One other option I absolutely have not tested, but should at least work locally, would be to handle your own recursion and change into each enumerated child directory using Push-Location and Pop-Location instead of bookkeeping junctions. Since you're dealing with relative paths instead of absolute paths at that point, you're very unlikely to hit PATH_MAX issues.
Vulture Culture fucked around with this message at 00:06 on Feb 26, 2015
|
#
¿
Feb 26, 2015 00:02
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
If you need better performance than background jobs can give you for tasks that are embarrassingly parallel, you can also consider runspaces, or workflows if you need more control over the way results are aggregated and returned. Workflows might be really helpful here just for the built-in checkpointing capabilities.
|
#
¿
Mar 14, 2015 16:51
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Treat parallelism in PowerShell the same way that you would in most other scripting languages: it will help you with asynchronous I/O-bound operations, but it will almost never improve the performance of a calculation.
|
#
¿
Jul 20, 2015 20:35
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
This is a reaaaaally niche request, so I'm not really hoping to strike gold, but you never know.
So, we're performing a Domino to Exchange migration and the migration product doesn't migrate permissions on anything (bit of a nightmare, really). As such, we're better off building a script that gets all the permissions on Domino and then another script that puts those permissions onto exchange automatically. Most of the stuff we'll probably be able to do, but I'm no expert at working with Domino and Powershell.
Do any of you guys have script that might get a list of the permissions/delegations on Domino?
Oddly, the first thing I found Googling "powershell domino" to see how remotely possible this even is covers ACLs specifically:
http://baldwin-ps.blogspot.com/2013/08/lotus-notes-and-powershell-retrieve-acl.html
You'll need to use their COM objects for basically all the automation.
|
#
¿
Sep 2, 2015 15:10
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Use VSO + Git. That way, you have a local repo and you can make sure if your PC explodes you're still covered by source control.
Bitbucket is another free option with unlimited private repositories.
|
#
¿
Sep 5, 2015 15:53
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
Followup on the git question:
Spent part of today reading up, and fairly comfortable with the basic concepts.
However; my use case is that:
I have my local repo; makes sense
Which I'll push to VSO for changes I'm happy with.
How would I go about also getting the VSO repo synced up with a DFS namespace/fileshare at work? Basically I'd like to have a share at work that is only (and autmatically) updated with changes that are pushed to the server.
Any suggestions there? I'd like as much automation as possible so the repo and share are as in-sync as possible without human intervention.
Create a repository on a shared drive. Create a scheduled task to automatically git pull your wanted branch(es) from VSO. Ensure it's read-only (i.e. only the user running that pull script can write to it).
|
#
¿
Sep 5, 2015 20:55
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
There's an awful lot of DSC resources for managing NTFS ACLs lying around. Anyone have a favorite?
|
#
¿
Jun 8, 2016 02:18
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
I'm interested in what you're using DSC for? I am just picking it up again after a year and the community isn't anything compared to Chef, which is a bit disappointing.
Nothing fancy, just automating the creation of some desktop VMs for our developers to make it easier to onboard people.
The community is definitely tiny next to Chef, and all of the documentation is terrible. But it's good enough, I guess?
|
#
¿
Jun 10, 2016 01:29
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 29, 2024 04:08
|
|
- Vulture Culture
- Jul 14, 2003
-
I was never enjoying it. I only eat it for the nutrients.
|
No, this is a one time thing, so say we've got 100 servers that need significant configuration changes, and they all go through similar steps, some of which may fail, need to be remediated, and then move on.
I've been thinking of making some custom objects that have name, sequence number, succeed/fail, scriptblock.
Then for each of the servers I can have it start task 1 as a job, periodically check to see if it finished, proceed to 2 on the ones that are done, and so on.
If Server 45 fails on step 9, I want to be able to tell someone to manually fix the problem, and then continue to step 10.
Are you able to make these changes idempotent? Might be easier to just use something like DSC resources and not worry about the workflow angle at all -- it will just pick up whatever needs to be changed.
|
#
¿
Jun 16, 2016 23:54
|
|