How to grant permission to private key from powershell
Unable to change password in AD
Hello,
I am trying to change the password for an existing user in AD through the script below. However, I am getting an error "Server Unwilling to process request".
The script is running on a Windows 2003 domain controller. What am I doing wrong?
$userAD = [ADSI]"LDAP://localhost:389/CN=Test User,cn=Users,DC=iamdev,dc=local"
$userAd.psbase.invoke("SetPassword","passwd123")
thanks
Find a computer in AD using Get-ADComputer -Filter
I use the following to find a computer in AD and works fine.
Get-ADComputer -Filter "name -eq 'pcname'"
But I need to use $pc = "pcname" first before searching it like below but it does not work. How to do that ? thanks.
$pc = "pcname"
Get-ADComputer -Filter "name -eq $pc"
Get-Distributuiongroup
I need a help. I m trying the following commands..
$GrpNameEditor = Get-PublicFolder -Identity "\" -Recurse | Get-PublicFolderClientPermission | where{$_.Accessrights -eq "Editor" -and $_.User -like '*Editor*'} | Format-List User$UserName = Get-DistributionGroup -Identity $GrpNameEditor | Format-Table ManagedBy
$UserName
The Get-DistributionGroup command is not accepting the Input Parameter.. How do I get through this...
Thanks & Regards,
Amit
Rename files in batch
Good afternoon
I currently have batches of files which have been scanned into our systems and are held in a central location, they already have the filename with the current date prefixed, however i was wondering if possible i could add the creationtime (just the time bit) added to the filename at this point before it gets processed
Currently this is the scenario
Item scanned on system as PDF document titled scanner1-19-07-2013(1).pdf / scanner1-19-07-2013(2).pdf, etc
(The titles are auto generated by our scanning system but unfortunately the time is not something which can be prefixed)
These are saved to a temporary location, i.e 'c:\temp'
At this point i wish powershell to add the creation 'time' to the filenames as after this the files are put through our processing system
The aim is for me to be able to report on the 'Time' the files were scanned / reached the c:\temp folder for reporting purposes
i.e how long has the document taken from being scanned to reaching the final destination?
I hope this makes sense
any Help / advice much appreciated
Regards
Barrie
Function to evaluate $args
I am attempting to write a function I can call at the start of several scripts so I can tell if an argument was passed, and control program flow. A script will either be called with no argument, or with "batch". The following is the function, but it seems that no matter what I pass, it returns $FALSE. I am wondering if $args is out of scope within a function, but have not been able to find anything that specifically states that. Can someone help? Here is the code:
function IsBatch { if ($args.count -eq 0) { return $FALSE } else { if ($args[0].toLower -eq "batch") { return $TRUE } else { return $FALSE } } }
Doug Bishop
Adding groups to local admin
Help for New-Mailcontact and Set-Contact
Hi,
Objective for the script:
I have been trying to write a script so I can create New-Mailcontact using CSV file, if not already exist in ActiveDirectory.
If already exist in Active Directory then skip New-MailContact command and just run Set-Contact.
Problem in the script: -
It does create new Mailcontact if not already exist in AD.
1) If MailContact exist in the AD it still tries to create that MailContact and then it errors it out since AD would not let it create because it is not unique and then it moves to next entry and does the same until it finds the entry which is new then obviously AD let it creates it.
2) It create a new Mailcontact but it never goes to Set-Contact.
In summary 2 problems
1) It does not skip the entry if that already exist in AD.
2) It never goes to Set-Contact.
===================
$CSV = Import-CSV F:\contacts\contacts1.csv
$Abc = Get-MailContact -OrganizationalUnit "OU=company_Contacts,OU=Contacts,DC=test,DC=com" $_.alias | Select alias
foreach ($entry in $Csv) {
if ($entry.mailnickname -ne $abc.alias)
{
New-MailContact -Name $entry.DisplayName -DisplayName $entry.DisplayName -FirstName $entry.givenName -LastName $entry.sn -OrganizationalUnit "OU=company_Contacts,OU=Contacts,DC=test,DC=com" -ExternalEmailAddress $entry.mail -Alias $entry.mailNickname
}
Else
{ set-contact -identity $entry.mailNickname -Phone $entry.telephoneNumber -MobilePhone $entry.Mobile -Office $entry.physicalDeliveryOfficeName -Title $entry.Title -Department $entry.Department
}
}
========================
Where am I going wrong?
Raman
get timings for ssas full cube process keep a log
Are there any scripts where you can get start end time of a cube rebuild. I know you can get the LOG of
the process, but would be nice to see start stop for each dim and Measure group.
Like
dim_items -- started 09:01:00
ended 09:02:15
This way you could monitor individual run times to monitor any spikes that maybe happening and be
proactive.
Thanks.
Archive AD machines?
Does anyone have a working PS that will find machines in AD that have not been active for 'x' amount of days and then move those machines to a different OU?
mqh7
access DateImported
There is a value just for picture files, DateImported. Since a lot of programs don't give access to it for sorting and such I would like to write a script that would assign the DateImported to the LastWriteTime. Something like:
PS C:\> (ls test.jpg).LastWriteTime = (ls test.jpg).DateImported
Except it doesn't know what DateImported is when I try it that way. Any ideas?
Thanks
Run Powershell script as Scheduled task, that uses Excel COM object
What am I missing here..
I have Powershell script that uses the Quest AD cmdlets to get computer information from AD and populate an Excel spreadsheet with the data.
The script works fine, so I created a batch file and started the script from there (which works fine as well). It populates the excel spreadsheet, saves and closes the file.
If I run the script as a scheduled task, I can see from the logging that it supposedly gets the computers from AD, and runs through them. But a file is never saved, I have tried to run the scheduled task with admin credentials.
What am I forgetting?
N00b question: force script to continue after terminating error
So, I'm a total n00b with powershell and as anyone starting out with something unfamiliar, currently my "love" for PS can only be expressed in expletives.
Anyway, having spent past 9 hours beating my head against the wall, I'm throwing in a towel.
Here's what I am trying to accomplish: On share \\server1\users$ I need to get a list of all folders where permission contains an unresolved SID, e.g. S-1...... This will help me identify all folders where I have to either clean up permissions or delete it, since user is no longer in AD and folder is not needed.
Simple, right? Well, every time script encounters a folder where I don't have permissions, it crashes with:
"GET-ACL Attempted to perform an unauthorized operation...".
I followed advise in here to http://blogs.technet.com/b/heyscriptingguy/archive/2009/09/14/hey-scripting-guy-september-14-2009.aspx help me parse paths and get permissions. I tried to make sense of this article, but it's all greek to me:
http://rkeithhill.wordpress.com/2009/08/03/effective-powershell-item-16-dealing-with-errors/
So,
1. What's the most effective way to dump permissions for folders
2. How to keep script from crashing each time it encounters a terminating error?
$FML = PowerShell
Update status: pending
Getting variables from a file
Microsoft Outlook 2010 Calender Permissions
Hi,
Iam using Office 365 email and outlook client on my computer, I have been trying to setup a calendar were a colleague can also access it and add events and delete if required. I've tried setting up a shared calendar but this does not work as they cannot edit the events. I've also tried to delegate control using the options in outlook however this gives an error message. I've been told that this could be done via powershell however I haven't been able to find this online. If someone can give me some help please it would be appreciated.
Many thanks
Gramzon
Compairing patches by name to what is on another computer
Basically I am trying to set up an array of file names that are patches for a program and when I run my script. It will check to see if that computer has those patches by looking for a folder (by a path) and checking at once to see if all the patches are there. If not then go to a location and drag them there. Say there are 5 patches, (file 0, file 1, file 2...3 and 4). If the user has file 1,2 and 4. Then go out and grab that specific files that they are missing. (Is there a shorter way to do this last part then a If-If Else statement? Here is what I have so far.
$ArrayMain = ((Get-ChildItem -path "c:\sw\Folder\file0.txt"),
(Get-childItem -path "c:\sw\Folder\file1.txt"),
(Get-ChildItem -path "c:\sw\Folder\file2.txt"),
( Get-ChildItem -path "c:\sw\Folder\file3.txt"),
(Get-ChildItem -path "c:\sw\Folder\file4.txt")) $UserPath = Get-ChildItem -path "c:\sw\Folder" if(!($UserPath -contains $ArrayMain)) { write-host "missing files" } else { write-host "same" }
PowerShell v1.0 to send an email
Hi, I am trying to send an email with PowerShell v1.0. I am running a command script in PowerShell and I have it outputting to a txt file. I have this setup on a schedule task to run once a month on my server. This command it setup to index
a document database. The command script I have works great then it outputs to the txt file great. But what I want to do is add some more lines of code to this PowerShell script to send me and email with the information in the txt file. So
I can just look at the email without having to log into the server if there is not problems with the index. What do I need to input to make this happen? Any help will be great!
Thank You,
Frank
System Administrator / Windows Server / Windows Powershell
Using Windows PowerShell (Window Server) is one of tasks that belongs to System Administrators exclusively, is that correct? Does a database programmer has anything to do with it?
MVPs, Can you please to make it clear so I can show it to my higher ups? Thank you.
Powershell run a command\filename based on dnshostname
I am trying to run test-connection and ping computers in AD I am able to do this but I would like to run wolcmd if I can't ping the computer. I would create a script with the wolcmd mac ip etc based on the result of my ping. What is happening now is that I can ping and get a 'true ' 'false' result . When I get a false result it calls a test script I created but it calls the script for all false pings. I want it to run only if the computer name I can not ping matches my wolcmd script name.
Hope this makes sense. I am new to Powershell and think I am missing something obvious.
here is what i have so far. I have it outputting to the screen so I can see what happens..some of this script I copied from the web.
Import-Module active*
$test=$null
Get-ADComputer -filter * -Searchbase 'OU=Desktops,DC=aaa,DC=aaa,DC=aaa' |
ForEach-Object {
$test=test-connection -CN $_.dnshostname -count 1 -buffersize 16 -quiet
if($test -match 'true')
{write-host -ForegroundColor green $_.dnshostname}
if($test -match 'false')
{write-host -ForegroundColor red $_.dnshostname}
if($test -match 'false')
{ get-childitem c:\scripts | where $_.dnshostname -like $_.filename | & c:\scripts\*.bat}}
Below are others I have tried:
#| where "'*.bat'" -match $_.dnshostname }}
#if($test -match 'false' ) {Invoke-Command {& c:\scripts\*.bat (where $_.dnshostname -like $_.filename)}}}