New answers tagged

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


0

Since it's a service that you're able to stop, then have the script disable the service, stop it, copy what you need, re-enable it, and then start it. In order to disable the service, you'll need to play with the registry. Here, there be dragons. The following contains potentially hazardous information. Proceed at your own risk. Export the following ...


0

First thing I see is when i run 'Get-ADComputer' it wants a filter. After the filter is applied i still dont see "accountdisabled" property for Get-AdComputer, I think you mean "Enabled" $computers = Get-ADComputer -Filter * | where {$_.Enabled -eq $false} You might want to change that filter before running. Edit: sorry; to find the properties run Get-...


0

I finally got it to work...Since the password file had to be encrypted by the user calling it (NT Authority\SYSTEM in my case) I called PSEXEC as the system account and interactive (psexec -s -i) to create the password file. After that, it was simple to create the Scheduled Task, running as SYSTEM to call powershell and the script file. Everything works ...


0

While there's probably a lot of ways to script this, I personally prefer to use a program designed with such a thing in mind. The program SyncBack comes to mind and it's capable of doing exactly what you're asking. It can backup files/folders, create tasks to run automatically without anyone logged in, and it can save credentials for the source and ...


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.


0

Using pssh could be a good solution. Here is an example. pssh -i -h /root/spark-ec2/slaves dir The dir command will run on all slaves. pssh comes preinstalled on all cluster.


0

When I complete automation projects or do automation training classes I'm always asked why I don't use Export-Csv. Microsoft claims Export-Csv is the same as ConvertTo-Csv except that it saves the output to the file. While that statement is literally correct, it's not a replacement for the tried and true code of: $Objects | ConvertTo-Csv -...


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.


0

To implement user5870571's suggestion with >> users.csv (in case your file is blank - mine was too) do the following: 1) save the below script to a .ps1 file. Note that I removed Export-Csv Import-Module ActiveDirectory $Age = Read-Host "Accounts that have not been logged into in the last how many days should be shown?" $When = ((Get-Date)...


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\...


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 ...


0

You can also install win32-openSSH by hand from https://github.com/PowerShell/Win32-OpenSSH or through Chocolatey https://chocolatey.org or even faster through Boxstarter (which utilizes Chocolatey under the hood) https://boxstarter.org (fast install https://boxstarter.org/packages/nr/win32-openssh ). It takes a little setup, but it is a native (yeah, for ...


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 ...


0

use the following as the lower part of your script: $destinationRoot = "C:\some\where\else" ForEach($folder in $FoldersWithOnlyOneFile) { # the folder to move to $destinationFolder = "$destinationRoot\$($Folder.Name)" # if it not exists, create the folder if (!(Test-Path $destinationFolder)) { New-Item -Path $destinationFolder -...


0

Within your 2nd foreach loop use some combination of the following $file = Get-ChildItem $Folder.FullName move-item $file.Fullname "C:\some\where\else" # moves only the file remove-item $folder.Fullname # remove empty source dir after file move move-item $folder.Fullname "C:\some\where\else" # moves the folder and the file


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 | ...


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, ...


0

You never use the $user value in the Get-ADUser call...try changing the $UsersX value to the parameters you need to send to Get-ADUser and substitute them in...and since you're reusing the same LdapFilter, might as well make that a variable as well. (Also, you're reusing the "OU=Users,OU=US-Location" three times, I assume that's just for example purposes?) ...


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 ...


0

Audit reports allow you to track any set-/add-/remove- actions against an object. Not sure if you will be able to capture the information you want, though. It would seem that it is the action of removing the license (deprovision mailbox) that is clearing the value.


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 ...


0

Remove the -Command from your script parameters and instead use -File . Command is meant to be used when you are entering powershell commands but you have a script file instead. Details here


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 ...


0

I was trying to solve this same problem and came up with the following. You'll want to define $location as well as change the addyears(-1) to which ever number of years you want. In this example -1 is 1 year ago. $Mailbox = Get-MailboxDatabase | Get-Mailbox Foreach ($MBX in $Mailbox) { $usermailbx = Get-Mailbox -identity $MBX | Get-MailboxStatistics $...


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....


0

If your primarily after "how many" and not which users or how often, you can get those numbers from the Server object in Perfmon. It has values for "Logons Total" and "Logons/sec"


0

I found a powershell script that might be helpful: https://gallery.technet.microsoft.com/scriptcenter/Reset-password-for-all-412fbc72


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. ...


0

PSReadline module provides this. To install is simple not sure what the requirements are but I think at least windows 10 for this method provided. If you dont have OneGet or not sure you can follow the instructions at PSReadline To install PSReadline without elevating privileges Install-Module PsReadline -Scope CurrentUser Check you have a powershell ...


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 ...


0

After the troubleshooting I have put in to this, my conclusion is simply that Test-Connection is returning a very unhelpful error message and/or misinterpreting the "Destination host unreachable" response being received from the router. If anyone else is seeing this I would suggest running a tracert to confirm whether there is any device in the route which ...


0

You can use powershell module WebAdministration, to view commandlets: (Get-Module WebAdministration).ExportedCmdlets For example, command to get web-sites: Get-Website To get names of AppPools: (Get-ChildItem IIS:\AppPools\).Name More information: https://technet.microsoft.com/ru-ru/library/ee790599.aspx



Top 50 recent answers are included