Hot answers tagged

5

Erm... You can't delete active files like this. You called a 64 bit powershell instance to delete a module for the 64bit shell. Powershell preloads modules (but doesn't necessarily install them) which locks the module file.


4

I think the exit code task scheduler is reporting is for running powershell.exe not your script. Try changing it to this: -ExecutionPolicy Bypass –NoProfile –Command "& {C:\ProgramData\ORGNAME\scripts\SetDNS.ps1; exit $LastExitCode}" > C:\ProgramData\ORGNAME\scripts\SetDNS.log $LastExitCode has the exit code of the your script, you have to bubble ...


4

The version of the module the DSC resources are part of was different between my local computer and the server. On my local computer, where my configuration gets converted to MOF files, I had version 2.2.0 (code snipped for brevity): instance of ******** as $********1ref { ModuleName = "********"; ModuleVersion = "2.2.0"; }; But the server had version 2....


2

You could do this with EC2 Run Command if you have that agent installed, though it may be a better fit for something like a Cloud-Init configuration that you put in the user-data for each instance. Alternatively consider using AWS OpsWorks to configure the nodes as desired at boot time, or generate a golden image with Packer such that the config is placed ...


2

It looks like you're trying to combine properties from multiple objects onto the output stream. I think the best way to accomplish your goal is to leverage calculated properties on your pipeline. However, in your code example MBXProps is an undeclared variable which may be the leading cause to why your process isn't working. Though you've likely cherry ...


2

user360071, here is a PowerShell script that will do what you want. Import-Module ActiveDirectory $Age = 30 $When = ((Get-Date).AddDays(-$Age)).Date $Members = (Get-ADGroupMember -Identity "Domain Admins" -Recursive).DistinguishedName Foreach ($Member in $Members) { Get-ADUser -Identity $Member -Property LastLogonDate | Where LastLogonDate -lt $When | ...


2

According to Microsoft TechNet, you don't want to add the user to the Remote Management Users group. You want to add the user to the WinRMRemoteWMIUsers_ Group. WinRMRemoteWMIUsers_ Group will give the user the ability to run remote PowerShell commands. Remote Management Users Group is for managing the server using Server Manager.


1

The share and the share permissions are set on MainShare. If you want share permissions on \FooBar\MainShare\SomeStuff\MyTarget then you would have to create a new share point directly to that folder


1

When using network resource file systems, and UNC paths, you should use the filesystem:: PSProvider in Powershell. Here's a couple examples: Test-Path "filesystem::\\127.0.0.1\c$" Test-Path "filesystem::\\$env:computername\c$" Adapting this process to your code should be as simple as: foreach ($server in $servers){ net use $server /USER:domain\...


1

In response to your original question, you could install mpssh- Mass Parallel SSH and use it to run commands on all your instances. The first time you run it, you may need to type "yes" 150 times, unless you want to ignore host key checking.


1

From having a quick look my impression is that the current ARSoft.Tools.Net versions (tried 2.2.4 and a few spot checks of versions before it) appear to be bugged with regards to TSIG signing. There appears to be an error causing the TTL is included twice in the TSIG record, which obviously offsets everything after, completely breaking any parsing of the ...


1

You can definitely do this with PowerShell (it's probably the easiest way to do it). If you want to understand more about how to do it I'd suggest reading this Technet 'Hey scripting guy' blog post, which covers it in pretty good detail. If you're looking for a ready rolled solution, you can check out this script. It will probably do what you need with a ...


1

There are a few recommendations I'd make with your current script. First off, a single large query is almost always going to perform better than many smaller queries. So rather than running get-aduser separately for each target OU, I would combine them into a single call using a higher level common OU as the search base. Obviously, this may end up returning ...


1

It depends on what the issue is. If you are not running under a user context at all, like under the SYSTEM account, then you might need to run as a particular user, which typically means specifying a username and password, which is often problematic. If the issue is that you currently have admin rights, but need to run something without those admin rights, ...


1

In my own scripts I use psexec in those situations. You have to specify username and password for a different account as well as an executable which then runs as the specified user. This is not pure PowerShell but good enough for me. It may be possible for a PowerShell script to do the same thing psexec does. But unless you find out, this should solve your ...


1

I don't think this has anything to do with the fact of it being Windows Server 2008 R2. My guess is that you're running non-english Windows Server. Adjust the following lines to match your language: [regex]$RegexAccountName = "Account Name:\s+\w+.*" [regex]$RegexDomainName = "Account Domain:\s+\w+.*" After doing that on my test machine, it worked fine. ...


1

The -Identity parameter will work with the mailbox alias, which I find to be the easiest way to specify a mailbox. You can get a list of aliases for all of your mailboxes by running simply get-mailbox. In addition: The Identity parameter specifies the mailbox that you want to view. You can use any value that uniquely identifies the mailbox. For ...



Only top voted, non community-wiki answers of a minimum length are eligible