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

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

Related

Internal Server Error in PowerShell cmdlets for Microsoft Dynamics CRM

On Windows Server 2012 Datacenter with Microsoft Dynamics CRM 2016 installed, I want to run a deployment command but for every commands I get this error: "(500) Internal Server Error".
I first run this:
Add-PSSnapin Microsoft.Crm.PowerShell
and it will work fine and when I check it with get-pssnapin and Get-Help *Crm*, every thing is fine and every thing that I need is registered. but when I want to run a cmdlets command like these, I face the error: Get-CrmSetting or Get-CrmCertificate or ...
For example for Get-CrmSetting TraceSettings it give me this error:
How can I solve this problem and error?
Thanks
According to this article, you might want to try:
Get-CrmSetting –SettingType TraceSettings
Here are a couple more items to investigate, from this article:
To use the XRM tooling cmdlets, you need PowerShell version 3.0 or
later. To check the version, open a PowerShell window and run the
following command: $Host
Set the execution policy to run the signed PowerShell scripts. To do
so, open a PowerShell window as an administrator and run the
following command: Set-ExecutionPolicy -ExecutionPolicy AllSigned
Verify the (CRMDeploymentServiceAppPool Application Pool identity) has SQL SEVER SysAdmin permission. This is needed to perform any CRM configuration changes and organizational operations.
Note: it does not matter if the account executing the PowerShell is a system admin or SQL server sysadmin because these operations are executed via the deployment web service.
Deployment Web Service (CRMDeploymentServiceAppPool Application Pool identity)
....Sysadmin permission on the instance of SQL Server to be used for the configuration and organization databases.
....
(500) Internal Server Error, refers to a HTTP response status code. This means that the Powershell command is calling a URL and the URL is reporting a error.
You need to know the URL to really find out what the problem is. One way you can get the URL, is downloading Fiddler Classic. Once installed, you have to enable HTTPS decryption.
In my case the URL was...
https://<my-crm-domain>/XrmDeployment/2011/deployment.svc?wsdl
When I ran this URL on the server where CRM is installed, I got an exception stating...
Could not load file or assembly 'Microsoft.Crm.Application.Components.Application'
All this meant, I needed to copy a file, Microsoft.Crm.Application.Components.Application.dll, from C:\Program Files\Dynamics 365\CRMWeb\bin into folder C:\Program Files\Dynamics 365\CRMWeb\XRMDeployment\bin.
Once this was done, the URL worked and therefor my PowerShell command as well.

Will a PowerShell script developed for a Windows 7 run on Win Server 2008 R2?

I have developed a large PowerShell script that has been refined on a Windows 7 64bit box and now I intend to run it on a Windows server 2008 r2. Assuming the PowerShell versions are the same, will there be any major issues with syntax in-between Win 7 and WS 2008 R2?
The script checks a lot of WMI and registry keys like GWmi Win32_NetworkLoginProfile and Get-Itemproperty -Path Registry::HKLM\Software\Microsoft\"Windows NT"\CurrentVersion\winlogon\
Most PowerShell information is driven towards managing servers so I assume I will be safe, but I want to see if you all can help me learn some lessons before I start banging my head against the wall.
Thanks
There are no syntax differences between PowerShell on Windows 7 and PowerShell on Windows Server 2008 R2. You may encounter differences in existing services, WMI classes, and registry keys, though.
First you should test it on a virtual machine to see if it works or not. Then try it on the physical machine. If it doesn't work, modify the code to the specific registry keys.
The short answer is yes. I run PSv4 on both my desktop and one of my servers running 08. Be sure to import the correct modules (if any) and allow for RPC in your firewall (And winrm) if applicable. One note- depending on what you run with the server, commands and functions are only as good as the version you run against (even when invoked). I ran into this problem as I scripted in v4 and environmentally my firm is almost all v2. Enabled -verbose error output and test in virtual machines or a loner laptop. (This is what I did). Good luck!

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.

move-item: access denied on server 2012 only

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.

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 :)