When I press f5 for a particular code which ran perfectly until yesterday, now the message shown is:
PS C:\Users\Ch> D:\Company\Automation\filename.ps1
That's all, the code isn't getting executed.
When I press f5 for a particular code which ran perfectly until yesterday, now the message shown is:
PS C:\Users\Ch> D:\Company\Automation\filename.ps1
That's all, the code isn't getting executed.
Hi all,
I'm using below BULK INSERT script to load the data into Temp table.
Now we want separate this script to powershell.
Please some body provide qualent script for BULK INSERT in Powershell
BULK
INSERT #temporary
FROM '''+@FilePath +'''
WITH
(
CODEPAGE = ''XYZ'',
DATAFILETYPE = ''char'',
FIELDTERMINATOR = '','',
ROWTERMINATOR = ''' + CHAR(10) + '''
)
Thanks in advance
SNIVAS
Dear All ,
How to find All VM details (disk type ,size ,VM name etc.) from specific CSV Volume.
Best Regards, Hussain
I am trying to search the entire forest with several child domains for user with the same displayname. I have a CSV with a list of users and trying to find the same display name is any other child domains. Im using something like this.
$users = import-csv "c:\temp\list.csv"
ForEach-Object {
Get-ADUser -server dc.contoso.com:3268 -LDAPFilter "(ObjectClass=user)(DisplayName=$_.dname)" | Select UserPrincipalName, DistinguishedName | Export-Csv $ExportFile -NoTypeInformation -Append}
the List.csv has
dname
User, test1
User, Test2
User, Test3
I am not a powershell guru but learning. Can anyone please let me know what i doing wrong in the above script. if i dont use forloop the above get-aduser gives me correct results.
I want to activate office 2013 on remote computers. (KMS & GP are not possible)
Ideally I want to send someone the powershell script to run which would activate locally.
The thing is I don't want the key that's in the script to be visible in plain text. IE I don't want them to open up the script & see the key & use it somewhere else.
All I've found at the moment is this: (which would be fine if I could mask the key somehow)
Activate Office:I need to run a batch file with a argument on a remote machine. The batch file is located on teh remote machine and it need to be ran from the root patch where the batch file resides.
This is what I tried.
Invoke-Command -ComputerName ServerName -ScriptBlock {cd D:\Appname; .\v.bat javatest}
I am getting the below error
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
BUILD FAILED
D:\AppName\build.xml:1720: Java returned: 1
Total time: 3 seconds
Any help will be much appreciated.
I have some DSC scripts written in powershell 5.0. I had my variables being picked properly and running when i had WMF 5.0 installed on my machine of April release. Today i upgraded it to Sep release(Production Preview) and when i tried running my DSCs my configuration file wasn't able to recognize the parameters that were declared with Validate Set property.
Below is the sample of how my DSC looks like
[DscResource()]
class TestDSC
{
[DscProperty(Key)]
[string]$TestKeyProperty
[DscProperty(Mandatory=$true)]
[ValidateSet("Value1","Value2","Value3")]
[string]$ValidateProperty
[TestDSC]Get()
{
----- Get Method -----
}
Set()
{
----- Set Method -----
}
[bool]Test()
{
----- Test Method -----
}
Configuration file:
Configuration Testing
{
node localhost
{
Import-DscResource -Name TestDSC
TestDSC dscTesting
{
TestKeyProperty = "TestValue"
ValidateProperty = "TestValidateValue"
}
}
}
Testing
The highlighted property shows error saying invalid argument.
I know enum can be used in place of ValidateSet to have a set of values to go into a property(i did not use enum as my valid set of values have spaces in them and i was not able to put values with spaces so i used ValidateSet), but ideally ValidateSet() is also supposed to work. Is this a change that was made in the Production Preview release?? What is the workaround for this?? If enum is the only way to work with, can anyone help me with understanding how to have enum values with spaces between them!!
Any help would be appreciated!!!
I have a much larger issue than this, but I believe this actually identifies my root problem, to wit
$string="Autodesk® Storm and Sanitary Analysis"
Write-Host$string
works great in the ISE, but that Registered Trademark symbol becomes a lower case r when run as a script. Verified in PS 2.0 and in 4.0. Anyone have any insights on a direction to pursue, if not an outright solution?
Thanks!
Gordon
Hi
I would like to setup a script to monitor users last password change and send them an email.
This is the script I came up with but... not working I think it's because the result of get-aduser query is :
----
user@domain.com
$FindUser = Get-ADUser -identity mickey -Properties * | Where { $_.passwordLastSet –gt (Get-Date).AddHours(-1) } | Select Mail $smtp = "exchange.com" $from = "Admin <admin@exchange.com>" $subject = "This is a Test of HTML Email" $body = "Dear <b><font color=red>$to</b></font> <br>" $body += "We are testing <b>HTML</b> email <br>" $body += "Click <a href=http://www.google.com>here</a> to open google <br>" #### Now send the email using \> Send-MailMessage send-MailMessage -SmtpServer $smtp -To $User -From $from -Subject $subject -Body $body -BodyAsHtml -Priority high ########### End of Script################
What am I doing wrong?
M
Maelito
Is there a way to make a System.Windows.Forms Button that can clear results out of a field?
Something like
$RButton = New-Object System.Windows.Forms.Button
$RButton.Location = New-Object System.Drawing.Size(122,550)
$RButton.Size = New-Object System.Drawing.Size(110,40)
$RButton.Text = "View DHCP Information"
$RButton.Add_Click({RInfo})
$Form.Controls.Add($RButton)
Hello Community,
I need to automate configuration configuration of a large number of servers (all 2012 R2). One Task is to enable BITS upload on the Default Web Site in IIS.
I found this one: http://blogs.msdn.com/b/wmi/archive/2010/04/03/configuring-bits-upload-server-with-powershell-and-adsi.aspx
But it dosn't work :-(
Thank you for your support
Miranda
P.S.: No we cannot use DSC at this point :-(
I'm setting up a test server at my job running 2008r2. I found this article about using power shell:
I created a folder named scripts, and I'm running this command but I keep getting this error. I am copying the command exactly as the article describes. Can some one tell me what I am doing wrong? Also, I tried to add a screenshot but I get a message saying:
Body text cannot contain images or links until we are able to verify your account.
I have posted to this forum before. How can I add a screen shot?
Thank You.
I just need the attributes populated and It will discard the attributes in blank.
Does Anybody how to do i? If is it possible?
TI
Hello,
I am still learning powershell so hopefully this is something fairly easy to do. I am looking at setting the manageby field where custom attribute field equals a value. I will insert my code below, which I think should work, but could possibly see why it wouldn't Any help would be great.
set-DistributionGroup -ManagedBy user1@domain.com, user2@domain.com | where-object {$_.CustomAttribute5 -like "test"}
Well, this is simple, can anyone help me to re-write this code but for the regular Powershell?
Add-PSSnapin Quest.ActiveRoles.ADManagement
$name = Read-Host "Coloque ID de usuario. Ej: Armando.Barreda" |
Get-QADuser | %{
$Object = $_.CanonicalName
$info = $Object
$Notes = @{"info"=$info}
Set-QADuser $_ -ObjectAttributes $Notes
} |
Move-QADObject -NewParentContainer 'assist-card.com.ar/Seguridad Informatica/Disabled Users by Script' |
Set-QADUser -Description $((Get-Date).ToString('dd/MM/yyyy')) -WebPage "Disabled - $($env:username)" -Title "" -Department "" -Company "" -Office "" |
Disable-QADUser |
Remove-QADMemberOf -RemoveAll
Thanks.
I have a Powershell script run by a standard user which starts a scheduled task to run some admin maintenance tasks. The scheduled task runs with full admin rights on the system. This allows the non-admin user to start the task on demand WITHOUT needing any admin credentials.
All this works well right now, except I would like for the scheduled task to be able to communicate info back to the logged in user regarding status of the task. If there were no privilege issues involved, I would use Start-Job, Receive-Job, etc. to get info back from the task. However, because the task runs under different credentials, I have to use Start-ScheduledTask which doesn't allow any interprocess communication that I can find.
In my current design, when the background job completes it schedules a 2nd task (running as the original user) which uses VBScript wshShell.Popup to display a message to the original user giving completion status info of the admin task. Not very elegant, I admit, AND it doesn't allow the user to see any progress messages while the task is running.
Can any of you Powershell gurus think of a way I can achieve my goals??
Thanx for any replies...
I'm trying to use the following command to learn how to start the default PDF reader from the command line.
(1) How do I modify this command to display the path?
get-process | Out-GridView
(2) When I use this command after double clicking on a PDF file in Windows 10, I don't see the reader process. Why not? What is the powershell command to see the reader and the path to its executable?
Thanks
Siegfried
siegfried heintze
How do I get the IssueWarningQuota value returned from get-mailbox into a format that I can use to perform math?
In my instance the value is being returned like this
9.659 GB (10,371,465,216 bytes)
My goal is to have it returned or converted to something like this:
10371465216
The overall goal is to set this as a variable which I can then use against the TotalItemSize of Get-MailboxStatistics to determine what percentage of usage a users mailbox.
Something like this, I just cannot get the IssueWarningQuota and TotalItemSize to return in a usable format.
$warning = get-mailbox user1 | select -ExpandProperty IssueWarningQuota $usage = Get-MailboxStatistics user1 | select -ExpandProperty TotalItemSize $p = $usage/$warning "{0:P2}" -f $p
Any help greatly appreciated!
-Paul
COM object has a method defined as
[id(15)] HRESULT MyMethod([out, retval] SAFEARRAY(IDispatch*) * ppModules);
Object is created using
$obj = new-object -com mytype
How can I call method MyMethod from PowerShell?
I've tried a few options but I always get an error like
Exception calling "MyMethod" with "1" argument(s): "Type mismatch..."
I have one user who is trying to run one of my scripts, and he's getting an error when the script gets to this line:
Get-ADUser $User
No other user is experiencing this problem. He gets the same error if he just types it in to the PS window. He reports to have this problem from multiple computers, but others trying from those same computers have no problem.
Strange, but if he enters
Get-ADUser 'HisAccountName' -Cred 'DomainName\HisAccountName'
and enters his password at the prompt it works fine.
Here are the error details:
Message : A call to SSPI failed, see inner exception. Data : {} InnerException : System.ServiceModel.Security.SecurityNegotiationException: A call to SSPI failed, see inner exception. ---> System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you --- End of inner exception stack trace --- at System.Net.Security.NegoState.StartSendAuthResetSignal(LazyAsyncResult lazyResult, Byte[] message, Exception exception) at System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult) at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel) at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUp grade(Stream stream, SecurityMessageProperty& remoteSecurity) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUp grade(Stream stream, SecurityMessageProperty& remoteSecurity) at System.ServiceModel.Channels.StreamSecurityUpgradeInitiatorBase.InitiateUpgrade(Stream stream) at System.ServiceModel.Channels.ConnectionUpgradeHelper.InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, IConnection& connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(ICo nnection connection, TimeoutHelper& timeoutHelper) at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.ActiveDirectory.WebServices.Proxy.Resource.Get(Message request) at Microsoft.ActiveDirectory.Management.AdwsConnection.SearchAnObject(ADSearchRequest request) TargetSite : Void ThrowAuthenticationRelatedExceptionIfAny(System.ServiceModel.CommunicationException) StackTrace : at Microsoft.ActiveDirectory.Management.AdwsConnection.ThrowAuthenticationRelatedExceptionIfAny(CommunicationException exception) at Microsoft.ActiveDirectory.Management.AdwsConnection.SearchAnObject(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.AdwsConnection.Search(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADSyncOperations. Search(ADSessionHandle handle, ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADObjectSearcher.GetRootDSE() at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase.GetRootDSE() at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase.GetConnectedStore() at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase.GetCmdletSessionInfo() at Microsoft.ActiveDirectory.Management.Commands.ADGetCmdletBase`3.ProcessRecordOverride() at Microsoft.ActiveDirectory.Management.Commands.ADCmdletBase.ProcessRecord() HelpLink : Source : Microsoft.ActiveDirectory.Management HResult : -2146233087Any ideas as to why this is happening, and how I can fix it? TIA.