Error : Exception calling "MoveTo" with "1" argument(s): "The server is unwilling to process the request. " - ou

I am trying to write a script to move OU of users in AD 2008
$Alias = "hareeshvm"
# Finding the location of the user account harveesm:
$Root = [ADSI]("LDAP://DC=corp,DC=bharatpetroleum,DC=com")
$searcher = new-object System.DirectoryServices.DirectorySearcher($root)
$searcher.filter = "(&(objectClass=user)(mailNickName= $Alias))"
$User = $searcher.findone()
# Binding the user account to $AUser and the OU to move to to $MovetoOU
$ADSPath = $User.Properties.adspath
$MoveToOU = [ADSI]("LDAP://OU=Temp,DC=corp,DC=bharatpetroleum,DC=com")
$AUser = [ADSI]("$ADSPath")
# Command to Do the actual move
$AUser.PSBase.moveto($MoveToOU)
And I am getting below mentioned error
Exception calling "MoveTo" with "1" argument(s): "The server is unwilling to process the request.
"
At D:\Ashish\MS Exchange\New User\newuserscreation.ps1:39 char:21
+ $AUser.PSBase.moveto <<<< ($MoveToOU)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
thx in advance

Related

Connect-MsolService using graph access tokens failed

I usually run a modified version of the script provided by Microsoft on how to “Convert per-user MFA enabled and enforced users to disabled”.
If I run it interactively, the cmdlet “Connect-MsolService” works like a charm. However, as soon as I tried to use the parameters “AdGraphAccessToken” and “MsGraphAccessToken” it throws the following errors:
Connect-MsolService : An unexpected error occurred.
At line:1 char:1
+Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAcces ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidHeaderException,Microsoft.Online.Administration.Automation.ConnectMsolService
Connect-MsolService : Exception of type 'Microsoft.Online.Administration.Automation.MicrosoftOnlineException' was thrown.
At line:1 char:1
+Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAcces ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo : OperationStopped: (:) [Connect-MsolService], MicrosoftOnlineException
+FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.MicrosoftOnlineException,Microsoft.Online.Administration.Automation.ConnectMsolService
When passing the same tokens to the cmdlet “Connect-AzureAD”, it goes as expected.
I use the following snippet for acquiring the tokens:
$TenantId = 'MyTenantId'
$Authority = 'https://login.microsoftonline.com/{0}/oauth2/v2.0/token' -f $TenantId
$ClientId = 'MyAzureActiveDirectoryAppId'
$ClientSecret = 'MyAzureActiveDirectoryAppSecret'
$Parameters =
#{
Authority = $Authority
ClientId = $ClientId
ClientSecret = (ConvertTo-SecureString -String $ClientSecret -AsPlainText -Force)
}
$AadAccessToken = (Get-MsalToken #Parameters -Scopes 'https://graph.windows.net/.default').AccessToken
$MsAccessToken = (Get-MsalToken #Parameters -Scopes 'https://graph.microsoft.com/.default').AccessToken
#Connect-AzureAD -AadAccessToken $AadAccessToken -MsAccessToken $MsAccessToken -AccountId $ClientId -TenantId $TenantId
Connect-MsolService -AdGraphAccessToken $AadAccessToken -MsGraphAccessToken $MsAccessToken -AzureEnvironment AzureCloud
I know that the modules MSOnline a AzureAD have been deprecated in favor of Microsoft.Graph, but since there is no other programmatic way to Enable per-user MFA I would kindly ask you people for some guidance: am I missing something here?
There is a way to create phoneAuthenticationMethod MFA using the MS graph which is still in beta phase:
https://learn.microsoft.com/en-us/graph/api/authentication-post-phonemethods?view=graph-rest-beta&tabs=powershell

Missing file (net.xml) in Running Environment Flow

On tutorial 01 from flow:Tutorial 01.
I executed the code
flow_params = dict(
exp_tag='ring_example',
env_name=AccelEnv,
network=RingNetwork,
simulator='traci',
sim=sim_params,
env=env_params,
net=net_params,
veh=vehicles,
initial=initial_config,
tls=traffic_lights,
)
# number of time steps
flow_params['env'].horizon = 3000
exp = Experiment(flow_params)
# run the sumo simulation
_ = exp.run(1, convert_to_csv=True)
I got an error afterward, here is the error
Error during start: [Errno 2] No such file or directory: '.../kernel/network/debug/cfg/ring_example_20201208-1332481607405568.58399.net.xml' Retrying in 1 seconds...
How should it be generated or where can it be found?
This is an issue with my file naming conversion. Apparently, the command to be called in
subprocess.call(
[
'netconvert -c "' + self.net_path + self.cfgfn +
'" --output-file="' + self.cfg_path + self.netfn +
'" --no-internal-links="false"'
],
stdout=subprocess.DEVNULL,
shell=True)
requires no spacing. In my case, I have my folder named "Machine Learning."

to type "System.Int32"Error:"Input string was not in a correct format

I Run the this power shell script
"$InstallPh\Database\bin\mysql.exe" -'uroot' -'e''select status from zibcatalog.zibmonitor where backupset="$BACKUPSET" AND operation="ZIB_BACKUP";' > 'c:\\auto\\firstbackup-result.txt'
Powershell throws this error message:
Cannot convert value "\Database\bin\mysql.exe" to type "System.Int32". Error: "Input string was not in a correct format."
At line:1 char:2
+ "$InstallPh\Database\bin\mysql.exe" -'uroot' -'e''select status from zibcatalog ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastFromStringToInteger
Your problems the way your trying to execute and pass the parameters to MySQL.exe. Try using the & operator to execute the exe file.
& "$InstallPh\Database\bin\mysql.exe" "-uroot -e'select status from zibcatalog.zibmonitor where backupset=`"$BACKUPSET`" AND operation=`"ZIB_BACKUP`";'" > 'c:\auto\firstbackup-result.txt'

EMR Job Failing

Folks,
The following python script is terminating with
job state = FAILED
and
Last State Change: Access denied checking streaming input path: s3n://elasticmapreduce/samples/wordcount/input/
Code:
import boto
import boto.emr
from boto.emr.step import StreamingStep
from boto.emr.bootstrap_action import BootstrapAction
import time
S3_BUCKET="mytesetbucket123asdf"
conn = boto.connect_emr()
step = StreamingStep(
name='Wordcount',
mapper='s3n://elasticmapreduce/samples/wordcount/wordSplitter.py',
reducer='aggregate',
input='s3n://elasticmapreduce/samples/wordcount/input/',
output='s3n://' + S3_BUCKET + '/wordcount/output/2013-10-25')
jobid = conn.run_jobflow(
name="test",
log_uri="s3://" + S3_BUCKET + "/logs/",
visible_to_all_users="True",
steps = [step],)
state = conn.describe_jobflow(jobid).state
print "job state = ", state
print "job id = ", jobid
while state != u'COMPLETED':
print time.localtime()
time.sleep(10)
state = conn.describe_jobflow(jobid).state
print conn.describe_jobflow(jobid)
print "job state = ", state
print "job id = ", jobid
print "final output can be found in s3://" + S3_BUCKET + "/output" + TIMESTAMP
print "try: $ s3cmd sync s3://" + S3_BUCKET + "/output" + TIMESTAMP + " ."
The problem is somewhere in boto... If we specify IAM user instead of using Roles, job works perfectly. EMR supports IAM Roles ofcourse... and the IAM role we tested with has full rights to execute any task, so its not a mis-configuration issue...

Error updating configuration template in AWS Bean Stalk

I tried to Update the configuration settings of a Configuration Template say "Beta Configuration" on Bean stalk with the following commands, but its throwing a error -
C:\Users\anand\Desktop>elastic-beanstalk-update-configuration-template -a "Application XYZ" -t Beta Configuration -d New Beta Configuration -s 32bit Amazon Linux
running Tomcat 7 -f options.txt
the settings in options.txt are -
<pre>{"ApplicationName"=>"Application XYZ", "DateCreated"=>1314430489.771, "DateUpd
ated"=>1314430489.771, "DeploymentStatus"=>nil, "Description"=>"", "EnvironmentN
ame"=>nil, "OptionSettings"=>[{"Namespace"=>"aws:elasticbeanstalk:sns:topics", "
OptionName"=>"Notification Topic Name", "Value"=>""}, {"Namespace"=>"aws:autosca
ling:trigger", "OptionName"=>"BreachDuration", "Value"=>"5"}, {"Namespace"=>"aws
:autoscaling:trigger", "OptionName"=>"LowerBreachScaleIncrement", "Value"=>"-1"}
, {"Namespace"=>"aws:elasticbeanstalk:application:environment", "OptionName"=>"A
WS_ACCESS_KEY_ID", "Value"=>""}, {"Namespace"=>"aws:elb:healthcheck", "OptionNam
e"=>"UnhealthyThreshold", "Value"=>"5"}, {"Namespace"=>"aws:elasticbeanstalk:app
lication:environment", "OptionName"=>"AWS_SECRET_KEY", "Value"=>""}, {"Namespace
"=>"aws:autoscaling:trigger", "OptionName"=>"LowerThreshold", "Value"=>"10"}, {"
Namespace"=>"aws:elasticbeanstalk:sns:topics", "OptionName"=>"Notification Endpo
int", "Value"=>"sanand#indavest.com"}, {"Namespace"=>"aws:autoscaling:launchco
nfiguration", "OptionName"=>"SecurityGroups", "Value"=>"elasticbeanstalk-default
, default, GSUI-Base"}, {"Namespace"=>"aws:elb:loadbalancer", "OptionName"=>"SSL
CertificateId", "Value"=>""}, {"Namespace"=>"aws:elasticbeanstalk:application:en
vironment", "OptionName"=>"PARAM5", "Value"=>""}, {"Namespace"=>"aws:elasticbean
stalk:application:environment", "OptionName"=>"JDBC_CONNECTION_STRING", "Value"=
>""}, {"Namespace"=>"aws:elb:healthcheck", "OptionName"=>"Timeout", "Value"=>"5"
}, {"Namespace"=>"aws:autoscaling:asg", "OptionName"=>"Cooldown", "Value"=>"360"
}, {"Namespace"=>"aws:autoscaling:asg", "OptionName"=>"Custom Availability Zones
", "Value"=>""}, {"Namespace"=>"aws:elasticbeanstalk:monitoring", "OptionName"=>
"Automatically Terminate Unhealthy Instances", "Value"=>"true"}, {"Namespace"=>"
aws:elasticbeanstalk:container:tomcat:jvmoptions", "OptionName"=>"XX:MaxPermSize
", "Value"=>"512m"}, {"Namespace"=>"aws:autoscaling:trigger", "OptionName"=>"Uni
t", "Value"=>"Percent"}, {"Namespace"=>"aws:elasticbeanstalk:container:tomcat:jv
moptions", "OptionName"=>"Xmx", "Value"=>"512m"}, {"Namespace"=>"aws:elasticbean
stalk:application", "OptionName"=>"Application Healthcheck URL", "Value"=>"/"},
{"Namespace"=>"aws:autoscaling:asg", "OptionName"=>"Availability Zones", "Value"
=>"Any 1"}, {"Namespace"=>"aws:elasticbeanstalk:sns:topics", "OptionName"=>"Noti
fication Topic ARN", "Value"=>""}, {"Namespace"=>"aws:elasticbeanstalk:container
:tomcat:jvmoptions", "OptionName"=>"JVM Options", "Value"=>"-Duser.timezone=Amer
ica/New_York"}, {"Namespace"=>"aws:elasticbeanstalk:application:environment", "O
ptionName"=>"PARAM1", "Value"=>""}, {"Namespace"=>"aws:elb:loadbalancer", "Optio
nName"=>"LoadBalancerHTTPSPort", "Value"=>"OFF"}, {"Namespace"=>"aws:elb:healthc
heck", "OptionName"=>"Interval", "Value"=>"30"}, {"Namespace"=>"aws:autoscaling:
trigger", "OptionName"=>"UpperBreachScaleIncrement", "Value"=>"1"}, {"Namespace"
=>"aws:autoscaling:trigger", "OptionName"=>"UpperThreshold", "Value"=>"70"}, {"N
amespace"=>"aws:autoscaling:launchconfiguration", "OptionName"=>"ImageId", "Valu
e"=>"ami-847xv6ea"}, {"Namespace"=>"aws:autoscaling:asg", "OptionName"=>"MinSize
", "Value"=>"1"}, {"Namespace"=>"aws:elasticbeanstalk:sns:topics", "OptionName"=
>"Notification Protocol", "Value"=>"email"}, {"Namespace"=>"aws:elasticbeanstalk
:hostmanager", "OptionName"=>"LogPublicationControl", "Value"=>"true"}, {"Namesp
ace"=>"aws:autoscaling:launchconfiguration", "OptionName"=>"MonitoringInterval",
"Value"=>"5 minute"}, {"Namespace"=>"aws:elasticbeanstalk:application:environme
nt", "OptionName"=>"PARAM2", "Value"=>""}, {"Namespace"=>"aws:elb:policies", "Op
tionName"=>"Stickiness Cookie Expiration", "Value"=>"0"}, {"Namespace"=>"aws:elb
:healthcheck", "OptionName"=>"HealthyThreshold", "Value"=>"3"}, {"Namespace"=>"a
ws:elasticbeanstalk:application:environment", "OptionName"=>"PARAM4", "Value"=>"
"}, {"Namespace"=>"aws:elb:policies", "OptionName"=>"Stickiness Policy", "Value"
=>"true"}, {"Namespace"=>"aws:autoscaling:trigger", "OptionName"=>"Statistic", "
Value"=>"Average"}, {"Namespace"=>"aws:autoscaling:trigger", "OptionName"=>"Meas
ureName", "Value"=>"CPUUtilization"}, {"Namespace"=>"aws:elasticbeanstalk:applic
ation:environment", "OptionName"=>"PARAM3", "Value"=>""}, {"Namespace"=>"aws:aut
oscaling:launchconfiguration", "OptionName"=>"EC2KeyName", "Value"=>"indavest"},
{"Namespace"=>"aws:autoscaling:asg", "OptionName"=>"MaxSize", "Value"=>"2"}, {"
Namespace"=>"aws:autoscaling:trigger", "OptionName"=>"Period", "Value"=>"5"}, {"
Namespace"=>"aws:elb:loadbalancer", "OptionName"=>"LoadBalancerHTTPPort", "Value
"=>"80"}, {"Namespace"=>"aws:autoscaling:launchconfiguration", "OptionName"=>"In
stanceType", "Value"=>"c1.medium"}, {"Namespace"=>"aws:elasticbeanstalk:containe
r:tomcat:jvmoptions", "OptionName"=>"Xms", "Value"=>"256m"}], "SolutionStackName
"=>"32bit Amazon Linux running Tomcat 7", "TemplateName"=>"Beta Configuration"}
</pre>
The error am getting is -
<pre>710: unexpected token at '{"ApplicationName"=>"General Sentiment", "DateCreated"
=>1314430489.771, "DateUpdated"=>1314430489.771, "DeploymentStatus"=>nil, "Description"=>"", "EnvironmentName"=>nil, "OptionSettings"=>[{"Namespace"=>"aws:elasticbeanstalk:sns:topics", " ....................................</pre>
please suggest me a solution for this error
the options.txt file should only be providing the data for the OptionSettings key in that data structure. Remove this from the top so the file starts with a [:
{
"ApplicationName" = > "Application XYZ", "DateCreated" = > 1314430489.771, "DateUpd
ated" = > 1314430489.771, "DeploymentStatus" = > nil, "Description" = > "", "EnvironmentN
ame" = > nil, "OptionSettings" = > [