Unable to use Power Shell AD cmdlets on Remote Server
1.Enter-PSSession
PS C:\Users\09094080> Enter-PSSession -ComputerName 'oadb1' -Credential 'quantacn\qsmcoa'
[oadb1]: PS C:\Users\qsmcoa\Documents>
2.Import-Module ActiveDirectory
[oadb1]: PS C:\Users\qsmcoa\Documents> Import-Module ActiveDirectory
警告: Error initializing default drive: 'Unable to contact the server. This may be because this
server does not exist, it is currently down, or it does not have the Active Directory Web
Services running.'.
[oadb1]: PS C:\Users\qsmcoa\Documents>
3. run the Active Directory WebServices
[oadb1]: PS C:\Users\qsmcoa\Documents> Import-Module ActiveDirectory
[oadb1]: PS C:\Users\qsmcoa\Documents>
4. Get-ADUser throw exception.
Whey? What can I do?
[oadb1]: PS C:\Users\qsmcoa\Documents> Import-Module ActiveDirectory
[oadb1]: PS C:\Users\qsmcoa\Documents> Get-ADUser '09094080'
Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have
the Active Directory Web Services running.
+ CategoryInfo :
+ FullyQualifiedErrorId : Unable to contact the server. This may be because this server does not exist, it is curr
ently down, or it does not have the Active Directory Web Services running.,Microsoft.ActiveDirectory.Management.Co
mmands.GetADUser
Make sure port TCP 9389 to access Active Directory Web Services is open from your remote server to your Domain Controller(s). It was my problem this morning...
Only now when I import-module ACtiveDirectory I get the following Message :
WARNING : Error initializing default drive : "A local error has occurred".
and I can't seem to find troubleshooting information anywhere...
Similar Messages
-
New-CMGlobalCondition unable to create New script Condition using Power Shell
I am using config Manger 2012 and trying to use power shell cmdlet to create a new Global Condition using PowerShell but its not working for me using this
Do not understand how to use that command any idea.
New-CMGlobalCondition -DataType Boolean -DeviceType Windows -FilePath file.ps1 -Name test -ScriptLanguage PowerShell
Error comes as
New-CMGlobalCondition : No object corresponds to the specified parameters.
At line:1 char:1
+ New-CMGlobalCondition -DataType Boolean -DeviceType Windows -FilePath file.ps1 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Confi...onditionCommand:NewGlobalConditionCommand) [New-CMGlobalCondition], I
temNotFoundException
+ FullyQualifiedErrorId : ItemNotFound,Microsoft.ConfigurationManagement.Cmdlets.AppModel.Commands.NewGlobalConditionCommandHi,
What's your version of SCCM? I ran this command line on SCCM 2012 R2 CU2.
It seems SCCM 2012 R2 CU2 fixed New-CMGlobalCondition cmdlet issue.
"The New-CMGlobalCondition cmdlet incorrectly requires use of the
-WhereClause parameter."
Description of Windows PowerShell changes in Cumulative Update 2 for System Center 2012 R2 Configuration Manager
Best Regards,
Joyce -
hi,
i am having a visual studio custom solution having page layouts implemented. In that solution i am having 1 summary links web part and in that i have hard coded few links and this is deployed on ion dev and staging env.
Now, the issue is : yesterday, customer came to me and asking me to change the links from http://abc to
http://xyz/ in this summary links. can anyone pls throw some light,such that i can change this link using a power shell script. i know if i go the VS solution and change the link and redeploy [ update-spsolution
command] will work.
but if the links are changing regularly , chnaging the vs solution and redeploying is not a good practice.
if i elaborate li'l bit, i am adding the screen shot : i need to get the summary link column's value and need to update[ delete xisting one and add new ones ]
is there any way , i can change the links using power shell script?
i tried the belwo power shells cript to get the page in the page layouts :
$web = get-spweb
"http://siteurl"
$pubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pagesListName = $pubWeb.PagesListName
$defaultAspxFile = $pubWeb.GetPublishingPage("$pagesListName/mycustomhome.aspx")
$summaryLinkFieldValue = New-Object
Microsoft.SharePoint.Publishing.Fields.SummaryLinkFieldValue
// here am getting the NULL VALUE
can i get the summary links field correctly and delete / modify the same?
help is appreciated!
##$groupLink = New-Object
Microsoft.SharePoint.Publishing.SummaryLink("My group")
#$groupLink.IsGroupHeader = $true $summaryLinkFieldValue.SummaryLinks.Add($groupLink)Hi Shabeaut,
Could you tell us why do you want to add a link web part to the master page for all pages?
I tested that Summary Links web part (and other types of web parts) added in the master page under Quick Launch couldn't be edited when I edit the pages inherited from v4.master page, it looks by design.
Have you tried using the Quick Launch to add the link instead if you want to show links in all pages.
Thanks
Daniel Yang
TechNet Community Support -
Create & Start UPS Service Using Power-Shell in SharePoint 2013
I want to know that is there a way to create a User Profile Synchronization Service using Power-Shell in a SharePoint 2013 Enterprise site? If so then how am I supposed to do that and start the User Profile Synchronization Service using the Power-Shell.
I'm seeking this help because the UPS service is stuck in Starting and both FIM Services are also not started but they are in Automatic start mode.
Could someone try to solve this matter.
Thanks,
regards,
Chiranthakastart it from powershell will not help you resolve the issue.
Try below articles:
http://myspexp.com/2011/04/28/user-profile-synchronization-servicehangs-on-starting-i-fixed-it/
troubleshoot this issue:http://www.harbar.net/articles/sp2010ups2.aspx
http://www.sharepointdiary.com/2012/09/user-profile-synchronization-service-stuck-at-starting.html#ixzz2aXArH7zX -
Using Power shell script how to hidden SharePoint existing features.
Hi Firends,
Using Power shell script how to hidden SharePoint existing features.
Please help me.
Thanks,
Tiru
TiruThe Hidden property is set within the solution, so you would need access to the source code in order to set it.
Trevor Seward
Follow or contact me at...
  
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
Hi,
Can anyone pls point me any link/ src code for deplyoing wsp using power shell. I know I can deploy it through Add-spsolution and install-spsolution, the issue is that, it will give "status - stuck in deploying scheduled..."
and i need to restart the sharepoint services - services.msc --> SP administration and timer services - and then i need to run the exceadmsvcjobs command to deploy / update the wsp successfully in solution store.
i mean, whats the power shell equivalent of these tasks. or anyone has already scripted these.
if i elaborate little bit, would like to know how to automatically Retract, Remove, Add and Deploy SharePoint 2010 WSP Solution Files with PowerShellok, i have found the same :
here its : hope this will help someone.
function wait4timer($solutionName)
$solutionName ="TestingWSP.wsp"
$solution = Get-SPSolution | where-object {$_.Name -eq $solutionName}
if ($solution -ne $null)
Write-Host "Waiting to finish soultion timer job" -ForegroundColor Green
while ($solution.JobExists -eq $true )
Write-Host "Please wait...Either a Retraction/Deployment is happening" -ForegroundColor DarkYellow
sleep 5
Write-Host "Finished the solution timer job" -ForegroundColor Green
try
# Get the WebApplicationURL
$MyWebApplicationUrl = "http://srvr:21778/";
# Get the Solution Name
$MywspName = "TestingWSP.wsp"
# Get the Path of the Solution
$MywspFullPath = "D:\myWorkspace\TestingWSP.wsp"
# Try to get the Installed Solutions on the Farm.
$MyInstalledSolution = Get-SPSolution | Where-Object Name -eq $MywspName
# Verify whether the Solution is installed on the Target Web Application
if($MyInstalledSolution -ne $null)
if($MyInstalledSolution.DeployedWebApplications.Count -gt 0)
wait4timer($MywspName)
# Solution is installed in atleast one WebApplication. Hence, uninstall from all the web applications.
# We need to unInstall from all the WebApplicaiton. If not, it will throw error while Removing the solution
Uninstall-SPSolution $MywspName -AllWebApplications:$true -confirm:$false
# Wait till the Timer jobs to Complete
wait4timer($MywspName)
Write-Host "Remove the Solution from the Farm" -ForegroundColor Green
# Remove the Solution from the Farm
Remove-SPSolution $MywspName -Confirm:$false
sleep 5
else
wait4timer($MywspName)
# Solution not deployed on any of the Web Application. Go ahead and Remove the Solution from the Farm
Remove-SPSolution $MywspName -Confirm:$false
sleep 3
wait4timer($MywspName)
# Add Solution to the Farm
Add-SPSolution -LiteralPath "$MywspFullPath"
# Install Solution to the WebApplication
#Install-SPSolution -Identity <SolutionName> -WebApplication <URLName> [-GACDeployment] [-CASPolicies]
install-spsolution -Identity $MywspName -WebApplication $MyWebApplicationUrl -GACDeployment #-FullTrustBinDeployment:$true -GACDeployment:$false -Force:$true
# Let the Timer Jobs get finishes
wait4timer($MywspName)
Write-Host "Successfully Deployed to the WebApplication" -ForegroundColor Green
catch
Write-Host "Exception Occuerd on DeployWSP : " $Error[0].Exception.Message -ForegroundColor Red
ref :
http://www.sharepointpals.com/post/How-to-Deploy-a-SharePoint-2013-Solution-(WSP)-in-the-Farm-using-PowerShell -
Get the web part properties of documeny lib view web part using power shell
Hi,
Am looking to get the propeties of a list view web part - a document library's list view web part- using PowerShell
Manually I am able to do the same: the steps followed by me is given below:
1) I went to the
http://srvr1:123/sites/enggtest/mydoclib1/forms/allitems.aspx
2) Edit the page
3) Edit the mydoclib1 view web part
4) go to the peroperties
5) Check the Server Render checkbox
is there anyway i can do this using power shell.The code below assumes that the webpart is at index 0:
$SiteUrl = "http://aissp2013/sites/TestSite/"
$pageURL = "http://aissp2013/sites/TestSite/Lists/MyList/AllItems.aspx"
$web = Get-SPWeb $SiteUrl
$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wp = $wpm.WebParts[0]
$wp.ServerRender = $true
$wpm.SaveChanges($wp)
Blog | SharePoint Learnings CodePlex Tools |
Export Version History To Excel |
Autocomplete Lookup Field -
Activate design manager (sandbox) solution using power shell - SP2013
Hi All,
I have a design manager (sandbox) solution and deployed in site collection. I am trying to upload the new version using power shell.
Uninstall-SPUserSolution , Remove-SPUserSolution, Add-SPUserSolution and finally doing Install-SPUserSolution on that time i am getting the following error " Install-SPUserSolution : This file may not be moved, deleted,
renamed, or otherwise edited." kindly help me for this issue.
Regards,
SanthoshCan you please provide more details on your solution package? Did you use SharePoint Design Manager to create design package? If that is the case then if you read the following article it reads and
"In SharePoint 2013 you cannot uninstall an imported design package, and you should never attempt to deactivate a design package through the solution gallery."
I think if you read the article it might be helpful.
http://msdn.microsoft.com/en-us/library/jj862342.aspx
Amit -
Programmatically create SPGroups using power shell
hi,
I wanna create sp groups programmatically using power shell,
can anyone pls point me in the right direction.
i have gone through this code:
$GroupName = "mygrp1"
$owner =""
$member =""
$Description =""
$SPWeb.SiteGroups.Add($GroupName, "", "","")
$SPGroup = $SPWeb.SiteGroups[$GroupName]
$SPWeb.RoleAssignments.Add($SPGroup)
$SPWeb.Dispose()
just wanted to know whether should i add few code related with sproleassignments/ sproeldefintions etc we used to do in SP OM through c#
help is appreciated!There are two parts.
1. Adding a group to the site collection.
2. assigning permissions to the group.
The PS script given below first ensures if the group exists or not and then executes the logic. If the group already exists, then it will not add group the site. I would recommed to test it in Dev environment and then use in Prod.
$site=Get-SPSite $siteCollectionUrl
$rootSite=$site.RootWeb
$member=$rootSite.Users["User_Name"]
$user=$rootSite.Users["Other_User_Name"]
try
$grp=$rootSite.SiteGroups["Group Name"]
catch
if($grp -eq $null)
$rootSite.SiteGroups.Add("Group Name",$member, $user, "Group Description")
$grp=$rootSite.SiteGroups["Group Name"]
$roleDef=$rootSite.RoleDefinitions.GetByType([Microsoft.SharePoint.SPRoleType]::Contributor)
$roleAssigns=New-Object -TypeName Microsoft.SharePoint.SpRoleAssignment -ArgumentList $grp
$roleAssigns.RoleDefinitionBindings.Add($roleDef)
$rootSite.RoleAssignments.Add($roleAssigns)
$rootSite.Update()
Pradip T. ------------- MCTS(SharePoint 2010/Web)|MCPD(Web Development) https://www.mcpvirtualbusinesscard.com/VBCServer/paddytakate/profile -
How to get site permissions using power shell ?
Hello,
I require to get list of granted permissions ( Group/users ) which we see from Site Actions > Site Permissions.
would you please let me know how can I fetch the same using power shell ?
Thanks and Regards,
Dipti ChhatrapatiHello,
I have found the same using following script :
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
#Define variables
$site = Get-SPSite "Site collection URL"
#Get all subsites for site collection
$web = $site.AllWebs
#Loop through each subsite and write permissions
foreach ($web in $web)
if (($web.permissions -ne $null) -and ($web.hasuniqueroleassignments -eq "True"))
Write-Output "****************************************"
Write-Output "Displaying site permissions for: $web"
$web.permissions | fl member, basepermissions
elseif ($web.hasuniqueroleassignments -ne "True")
Write-Output "****************************************"
Write-Output "Displaying site permissions for: $web"
"$web inherits permissions from $site"
Write-Host "Finished."
$site.dispose()
$web.dispose()
Hope it helps others !
Thanks and Regards,
Dipti
Dipti Chhatrapati -
Remote managment Exchange 2013 SP1 from C# code using Power-Shell.
Hello,
Sorry if I am describing something wrong, but it is first time I am using Microsoft development forum.
I am trying to built library that will manage Exchange remotely using C# code (VS 2012) and Power-Shell ver.4.0. My workstation and the actual Exchange server physically placed in different domains. In order to test functionalities I am using
user that is member of all administrating and management groups in the appropriative domain. Remote Power-Shell is enabled on Exchange.
In order to connect to the Service I am using that part of code :
internal static bool RedirectionUrlValidationCallback(string redirectionUrl)
bool result = false;
var redirectionUri = new Uri(redirectionUrl);
if (redirectionUri.Scheme.Equals("https"))
result = true;
return result;
internal static ExchangeService ConnectToService(ExchangeVersion version,
string userName,
string emailAddress,
string password,
string domainName,
ref Uri autodiscoverUrl)
ExchangeService service;
try
service = new ExchangeService(version);
service.Credentials = new WebCredentials(userName, password, domainName);
if (autodiscoverUrl.IsNull())
var ads = new AutodiscoverService();
// Enable tracing.
ads.TraceEnabled = true;
// Set the credentials.
ads.Credentials = service.Credentials;
// Prevent the AutodiscoverService from looking in the local Active Directory
// for the Exchange Web Services Services SCP.
ads.EnableScpLookup = false;
// Specify a redirection URL validation
//callback that returns true for valid URLs.
ads.RedirectionUrlValidationCallback = RedirectionUrlValidationCallback;
// Get the Exchange Web Services URL for the user’s mailbox.
var response = ads.GetUserSettings(emailAddress, UserSettingName.InternalEwsUrl);
// Extract the Exchange Web Services URL from the response.
autodiscoverUrl = new Uri(response.Settings[UserSettingName.InternalEwsUrl].ToString());
// Update Service Url
service.Url = autodiscoverUrl;
else
service.Url = autodiscoverUrl;
catch (FormatException fe) // The user principal name(email) is in a bad format. UPN format is needed.
LoggingFactory.LogException(fe);
return null;
catch (AutodiscoverLocalException ale)
LoggingFactory.LogException(ale);
return null;
catch (Exception e)
LoggingFactory.LogException(e);
return null;
return service;
Then I am trying to reach existing mailbox of that user, using this part of code :
try
var runSpace = getRunspace();
var pwShell = PowerShell.Create();
pwShell.Runspace = runSpace;
var command = new PSCommand();
command.AddCommand("Get-Mailbox");
command.AddParameter("Identity", userPrincipalName);
command.AddParameter("RecipientTypeDetails", recipientType);
pwShell.Commands = command;
var result = pwShell.Invoke();
if (result.IsNotNull() && result.Any())
// TODO : fill appropriative DTO and return it.
else
// TODO : send back appropriative error.
closeRunSpace(runSpace);
catch (Exception e)
// TODO : log the exception and send back appropriative error.
private Runspace getRunspace()
var runSpaceConfig = RunspaceConfiguration.Create();
var runSpace = RunspaceFactory.CreateRunspace(runSpaceConfig);
PSSnapInException snapEx;
var psInfo = runSpaceConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.E2010", out snapEx);
runSpace.Open();
return runSpace;
private void closeRunSpace(Runspace runSpace)
runSpace.Close();
runSpace.Dispose();
With this part I had problem. I received exception that appropriative Snap-in is not installed on my computer. I had no installation disk of Exchange in order to install Management Tool (as I understand this is the way to add needed part) so I changed run
space activation to that part of code :
private Runspace getRunspace()
var newCredentials = (PSCredential)null;
var connectionInfo = new WSManConnectionInfo(new Uri("http://exchange.domainname.local/powershell?serializationLevel=Full"),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange",
newCredentials);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
var runSpace = RunspaceFactory.CreateRunspace(connectionInfo);
runSpace.Open();
return runSpace;
Now I am receiving exception :
"Connecting to remote server exchange.domainname.local failed with the following error message :
[ClientAccessServer=exchange,BackEndServer=exchange.domainname.local,RequestId=....,TimeStamp=...]
Access is denied. For more information, see the about_Remote_Troubleshooting Help topic."
Please help me to understand what I am doing wrong.
Thank you.
Alexander.In Exchange 2010 you should be using Remote Powershell not local powershell and the snap-in. Here is a sample that may help you:
http://blogs.msdn.com/b/dvespa/archive/2009/10/22/how-to-call-exchange-2010-cmdlet-s-using-remote-powershell-in-code.aspx -
Hi,
I am trying to launch Amazon EC2 windows server 2008 R2 instance using AWS Auto Scaling feature. I have used cusmized AMI in Autoscaling Launch configuration to launch an instance.I have placed Power Shell script in AMI.
The responsibility of script is to download code from AWS S3 and deploy in IIS server while windows startup first time.
When i check status, IIS is started succesfully. But default Application pool is not started.
To resolve this issue i have written one scheduled script. It helps to start the application pool if any application pool is in stopped state.
After this Application pool is started but i am not able to communicate with IIS server through browser.
Please help any one to resolve this issue.
Thanks in advanceHi Vchreddy,
For the IIS issue, we recommend you can post in IIS forum for more effective support:
http://forums.iis.net/
Thanks for your understanding. -
Using power shell function and SQL Table
I have a table holding file path of over 1 million documents. so like column one is documentID and column two is full file path.
Now, I want to get the file size of each of the documents. I have a function in power shell that gets the size of a file given file path.
My problem, is I do not know how to use that function and the table to get the size of each of the files(documents).
Help Much Appreciated!!
ebroI am not clear with your questions sir. Do you mean the category this question belongs too? If so, may be some body could help redirect the question to the appropriate place.
So what category does this belong too CM12 or Powershell?
http://www.enhansoft.com/ -
Changing a line in text using power shell
END235220140204081233000000056
HDR235220140205081243000000000
I have the lines above, i just need to get a few numbers out of the line.
out put preferably will be like
235220140204
235220140205
any help will be greatly appreciatedthis is working good, the only problem is it doesnt contain the rest of the data, i need the rest as well
example
HDR235220140203081815000000000 X00510 000006600 X00520
000010000 X00530 000007100 END235220140203081815000000056X
i need this to look like
235220140203
00510 00000660000520
00001000000530
000007100
235220140203
thanks
What I have noticed is that you are not a technician and do not know data or PowerShell at all. I recommend that you obtain the help of a consultant if this is of any importance. Your questions seem to be missing the point of how data works and how
to manipulate it.
Remember that initially you wanted all of the file broken at the 'X' character. Now it appears you just want it broken by altering the HDR and END bits. You need to rethink what you are doing and ask a consistent question. We can thrash back
and forth and not get anywhere because it is very difficult to understand what you are trying to do.
When dealing with porting of data between two tools it is important to both understand how the data is generated and how it is to be consumed, Once we have a clear idea of this it is usually fairly easy to create a conversion tool. By thrashing
back and forth this process can be made to be very difficult.
¯\_(ツ)_/¯
this is a very unusual file and thats why i need help with that, I am working with data bases mostly and very new with power shell and trying to learn, i am trying to make it as understandable as possible, and i appreciate all the help that i can get, but i
really don't need to read any insult here and you dont have to help me, -
Set the column order in document library using power shell
hi all,
am looking for a power shell script which set the column order in the document library, when i try to upload a document.
ie; i am uploading a doc to the doc lib. which has the below columns:
columnA - [choice field - mandatory ]
columnB - [lookup field - mandatory ]
columnC - [single line of text - optional ]
columnD - [choice field - optional ]
columnE - [choice field - mandatory ]
now when the end user uploads a document in my doc lib, i would like to see the mandatory columns takes up the top order and then optional fields.
columnA
columnB
columnE
columnC
columnD
so, is there any script, through which i can set the mandatory columns which will be coming in top and the optional fields as next orderThis is sample PowerShell code to reorder fields in a content type of a list.
$web = Get-SPWeb http://aissp2013/sites/TestSite
$list = $web.Lists["MyList"]
$contentType = $list.ContentTypes | where {$_.Name –eq "MyTestCT"}
$ctArray = "Title","ColumnA","ColumnB","ColumnD","ColumnC"
$contentType.FieldLinks.Reorder($ctArray)
$contentType.Update()
Blog | SharePoint Learnings CodePlex Tools |
Export Version History To Excel |
Autocomplete Lookup Field
Maybe you are looking for
-
Can only import one song at a time from a CD, then get conversion error.
I have been using iTunes for several years to import tracks from CDs. Until now I have not really experienced any problems - though I have not had need to do so for some time. I have just tried importing a few new CDs and am experiencing the follow
-
I need help with installation. Error Message: "Adobe bootstrapper for single installation has encountered a problem."
-
In an older computer should I install an older version of Premiere Pro for DV editing?
Hi all. I will try to make sense out of my question. I have a Pentium D, 3.60GHz 4gig ram windows 7 64bit computer. Installed I have Premiere Pro CS5. It seems to be working fine for DV editing since I do basic stuff (couple of filters, etc.). I
-
Configuration Guide for Time Management
Can anyone send me the configuration guide for Time Management
-
Bom for component allocation in routing
I have created Sales order Bom. When I create normal routing and go for component allocation then system asks for Bom creation. Why system is not considering sales order bom in Normal routing for component allocation?