move-item: access denied on server 2012 only - powershell

I am running a PS script that people's personal drives to another location when they are terminated. Script runs fine when the users drive is on a 2003 or 2008 server, but I get an error when the drive is on a 2012 server.
"move-item: Acces to the path '[\P drive path]' is denied.
Checked my group's rights to the file servers, and they are the same. Do not know 2012 well enough to know why this would be bombing out on that server only. Any ideas?

Found answer here, should have looked deeper.
Seems it cannot be done with move-item. When I said it worked under Server 2008, well, it did, but only because the user profile containers for a certain number of users is on the same file server/drive as where the terminations were being moved to. The other bunch, were on another file server, so move-item cant be used. Copy-item/Remove-item seems to work, just have to work on some error handling.

Related

Unix permissions needed when running Powershell script

As a final step in our AD account creation process that is being moved to a powershell script a few folders need to be created on the filer for users and I am coming unstuck with permissions.
I am just using the basic new-item command to create folder but the locations need unix permissions (775) set before anything can be created. I can't go there and right click in Windows explorer and click new.. and the powershell script is being bounced also due to permissions.
The reasoning from one of the tech guys here is that I am trying to create a sub folder via smb mount from Windows using ntfs permissions. There is no correlation to unix permissions and any of our Linux users won't be able to access / use the location created for them.
Sorry if that is a clumsy way of explaining it, I am not a systems engineer, just the guy trying to translate a whole heap if pearl scripts into a new powershell process.
Thank you
S.

Powershell doesn't open - error "Path cannot be the empty string or all whitespace"

I'm simply trying to open Powershell on my server. It opens for about 5 seconds and then closes, not showing any error before it closes or anything. The only thing I can see is in the Windows Powershell Event Log is that it gives the following error:
"Settings: Path cannot be the empty string or all whitespace."
I'm running WMF 4, Server 2012 R2, Exchange Server 2016 (not that I think that has anything to do with it). Any other post I've seen when I google " Powershell Path cannot be the empty string or all whitespace" always seems to have to do with someone programming. I'm just trying to open powershell.
Turns out it was a group policy setting, specifically "Computer Configuration\Policies\Windows Components\Windows Powershell\Turn on Powershell Transcripting." It had been turned on in our domain because Powershell V5 is being/has been pushed out to everyone (except for our Exchange Servers). Once I changed the setting on a GPO closer to my Exchange Servers, did a gpupdate, then restarted the server, it started working again just fine.
Also, whoever downvoted my question, would you be so kind to explain why it was downvoted? Or are you just going to be a drive by downvoter?

Powershell - Create Large Number of Shares and Permissions

I tried about a dozen PowerShell scripts that I found and not one even created a single share.
We are migrating from Win 2008 and SQL Server 2008 R2 to Windows 2012 and SQL Server 2014.
I have to create a ton of shares and assign a lot of varying permissions.
I'm looking for (ideally) a Powershell script (but can live with VB or anything else) that can go through a list of shares and permissions and create/assign them.
For example
E:\Folder1\A Share1 Domain\Tom Read
E:\Folder1\A Share1 Domain\Dick Full
E:\Folder1\A Share1 Domain\Harry Change
So it would go through every line, see if the share exists, if not create it, then assign the permissions.
On Server 2012R2 you can use the New-SmbShare cmdlet : https://technet.microsoft.com/en-us/library/jj635722(v=wps.630).aspx
On older versions you have to fall back to WMI to do it :https://msdn.microsoft.com/en-us/library/aa389393(v=vs.85).aspx (the article even has a PS example).
With Set-Acl you can set the ACLs for the shares.
As you can see all the tools to acomplish this are available in a default installation of Windows Server.

PowerShell v2 Server 2003 - Cannot Find Path - Path definitely exists

Usually I can find an answer to PowerShell questions by researching forums and adapting. However, after searching high and low, I cannot find an answer.
I am logged in as a domain administrator working on two enterprise servers in a test domain. $Server2003 is Windows 2003 server running PS v2. $Server2008 is Windows 2008 R2.
Problem: When I am working from $Server2003 I cannot use any commands to access or verify information on $Server2008. This error happens regardless of who the administrator is.
I have used PowerShell fairly extensively in our environments and haven't run into this error before. The error is not present when running commands from $Server2008 on $Server2003. In addition the error is not present when running commands from a production domain. I can also ping the 2003 or 2008 server regardless of which machine I am logged in as.
Examples:
From $Server2008: ping $Server2003 - returns pings
From $Server2003: ping $Server2008 - returns pings
From $Server2003: test-path \\$Server2008\D$\ - Get-ChildItem : Cannot find path '\\$Server2008\D$\' because it does not exist
From $Server2008: test-path \\$Server2003\D$\ - True
The commands I want to run are a lot more complex than test-path; however, if I cannot get the simple command to work I doubt I'll have much luck with a complex one.
The two servers have the same domain, are in the same forest, and have the same domain controllers.
Any ideas where to start?
EDIT: Wanted to add that I have tried using test path from Server2003 to a different 2008 server located in our dev environment (same domain) and it runs the test-path and commands successfully.
can you access the 2008 server remotely by other means? Like the Services MMC? Also, what if you create a share on 2008 rather than rely on the admin share?
The cannot find path error means that it doesn't exist or you don't have permissions. Does it work from a dos prompt?
UPDATE
I just noticed that you used single quotes, the variable will not expand. Enclose it in double wotes and try again

Powershell v2 remoting and delegation

I have installed Powershell V2 on 2 machines and run Enable-PsRemoting on both of them. Both machines are Win 2003 R2 and are joined to the same active directory domain and I can successfully run commands remotely. So PS remoting is working between the local server and remote server.
But when I try to access a share on a 3rd server (dir \someOtherServer\builds), which is also Win 2003 R2 and joined to the same active directory, I get the error:
Get-ChildItem : Cannot find path '\someOtherServer\builds' because it does not exist.
So what does it take to get this "hop" to work? Is it the delegation settings (in the active directory) to the remote machine? Are there any settings that can be done when creating a PSSession that will make the hop to work?
I addressed this issue for Workgroups in a blog post. I think the info should apply to domains but I haven't tested in a domain. Anyway, see if it helps. FYI, the solution involves Enable-WSManCredSSP and the Authentication parameter to Enter-PSSession.
It's can be many causes of that. If kerberos auth, check the time on all servers. It must be sync. It may be DNS resolution problem. Need more detailed problem description/
Sorry fo bad english :). If something wrong, please correct me :)