Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Swink
Apr 18, 2006
Left Side <--- Many Whelps
Amazing discovery: run "invoke-item ." To open the current directory in Explorer.

But use the alias:

code:
ii  .

Adbot
ADBOT LOVES YOU

Swink
Apr 18, 2006
Left Side <--- Many Whelps
I often export mailboxes from exchange using New-MailboxExportRequest. I then check the progress by rnning Get-Mailboxexportrequest before going on with the next step in the task. (usually delete mailbox)

How can I write a script that will perform the export and wait for the export to complete before running another command?

Swink
Apr 18, 2006
Left Side <--- Many Whelps
Here's an easy one that for some reason I am just not seeing the solution to. I'm blaming holiday booze.

I want to:

*Get a list of mailboxes
*If those mailboxes dont already have an Out of Office reply set,
*apply my generic out of office reply.


code:
$users = Get-Maibox -OrganizationalUnit "OU=Staff,DC=company,DC=com"

foreach ($user in $users) {

if (get-mailboxAutoReplyConfiguration $user.mailbox -AutoReplyState -ne "disabled") { # <-- this part is not right at all

Set-MailboxAutoReplyConfiguration -Identity $user -AutoReplyState Scheduled -StartTime "12/23/2014 5:30pm" -EndTime "01/04/2015 5:00pm" -ExternalMessage $replytext -ExternalAudience:All -internalMessage $null

}
}

Phone posting but I think that syntax is ok.


Also bonus for any Melbourne goons: There's a Melbourne Powershell usergroup firing up (finally). This dude is running it: https://twitter.com/david_obrien

Swink
Apr 18, 2006
Left Side <--- Many Whelps
2010 SP3 supports installing PS 3.0

Swink
Apr 18, 2006
Left Side <--- Many Whelps
Ask me about expiring staff who decide to stay on for a few extra days.

Swink
Apr 18, 2006
Left Side <--- Many Whelps
The disable-mailbox exchange cmdlet removes the mailbox but only disables the AD user.

*please check this is correct before running it.

Swink
Apr 18, 2006
Left Side <--- Many Whelps
I'm creating a new script with parameters but they are not working.

I've saved the file as new-user.ps1 and when I run ./new-user.ps1 from the console I expect to the able to tab through the available parameters.

Am I missing something painfully obvious here?

code:
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True)]
   [ValidateSet("Blue", "White")]
   [string]$brand,
	
   [Parameter(Mandatory=$True)]
   [ValidateSet("Sydney","Melbourne")]
   [string]$location,
   
   [Parameter(Mandatory=$True)]
   [string]$username= $(Read-Host "Please provide the username")
)
Edit - it was because I had errors elsewhere that halted the script. All good.

Swink fucked around with this message at 08:19 on Mar 10, 2016

Swink
Apr 18, 2006
Left Side <--- Many Whelps
Some sweet Done Jones action from the Powershell Summit thing https://www.youtube.com/watch?v=playlist

There's like 30 videos on all kinds of topics.


The forums arent letting me post the link to the playlist so here's a single video. You can find your way from there.

https://www.youtube.com/watch?v=KprrLkjPq_c

Swink fucked around with this message at 01:58 on Apr 16, 2016

Swink
Apr 18, 2006
Left Side <--- Many Whelps
I've just upgraded my Win7 laptop to Win10. I'm missing the package management cmdlets. Find-module, find-package etc. What gives?


There they are, I had to run as admin. Go me!

Swink fucked around with this message at 12:21 on May 27, 2016

Swink
Apr 18, 2006
Left Side <--- Many Whelps
Today I wrote a script to poll a bunch of IP addresses (I was trying to find a specific host among an otherwise empty subnet. Document your networks plz)

It was super quick and dirty and I used this little trick which I thought was worth sharing

"1..100" builds a nice array of numbers.

code:

1..254 | foreach ($element) {

    if (Test-Connection 192.168.1.$_ -Quiet) {

        Write-Host "Found something on: .$_"
        
   }

   }

Swink
Apr 18, 2006
Left Side <--- Many Whelps
Just pitching in to say that if you're writing scripts with % and ? or whatever the hell, you are the devil. There are no prizes for brevity here, you should be as explicit as possible.



Vulture Culture posted:

There's an awful lot of DSC resources for managing NTFS ACLs lying around. Anyone have a favorite?

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.

Swink
Apr 18, 2006
Left Side <--- Many Whelps
The respect I have for the author of that is matched only by my desire to punch them in the stomach.

Adbot
ADBOT LOVES YOU

Swink
Apr 18, 2006
Left Side <--- Many Whelps
What version are you running? I've had problems with UNC paths with version 3.

My specific problem was trying to invoke commands from a UNC path. The shell just wouldn't see the file.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply