I need AD Health status via Power Shell script
Dear All,
I need AD Health power shell script and it has to be sent via email as report on daily basis
Can anyone help on this?
Thanks,
Pushparaj
I found below script which can be used, but i would request run these scirpts in test environment before executing in production.
http://fearthemonkey.co.uk/using-powershell-to-perform-dc-health-checks/
http://www.wolffhaven45.com/blog/powershell/automate-some-active-directory-health-checks-via-powershell/
You can also search for scripts in below repository.
http://gallery.technet.microsoft.com/
Also, for scripting related request, its better to post the thread in dedicated scripting/powershell forum.
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
Awinish Vishwakarma - MVP
My Blog: awinish.wordpress.com
Disclaimer This posting is provided AS-IS with no warranties/guarantees and confers no rights.
Similar Messages
-
How can I list print queues per server via power shell script
Hello,
we are managing many print servers on our domain environment, now for auditing purpose I need to report print queues per server, and it seems bit difficult task doing it via GUI in print management view, could someone help me with script which
gets me the no. of print queues on each print server.
Also I need to list all the print drivers installed on each print servers.
I tried to list the drivers " Get-WmiObject win32_printerDriver -filter " but this will get me complete information about the driver, I need to list only the driver name (-filter) either _RELPATH or _PATH
dibuYou can also use WMI like this:
(get-WmiObject win32_printer -computer ws702).count
I don't understand what you mean by list only. Just select what you need.
See: http://technet.microsoft.com/en-us/scriptcenter/dd742419
That will give you some basic background on how to use PowerShell to get the properties of objects.
¯\_(ツ)_/¯ -
Scan a Excel file via power Shell
Hi;
I have in input a Excel File (3 colunms) to create automatically the sites collections (CS) and thier sites (SITES) :
INUPUT :
DECC CS SITES
dec1 paris site1
dec1 paris site2
dec1 paris site3
dec1 nice site1
dec1 nice site2
dec1 nimes site1
dec2 ales site1
dec2 ales site2
dec2 sete site1
etc...
How scan the Excel file via power shell to create the sites + collections in reading like this :
dec 1 -- paris
-- site1 & site2 & site3
-- nice
-- site1 & site 2
-- nimes
-- site1
dec 2 -- ales
-- site1 & site2
-- sete
-- site1
Regards;Hello soussou97,
My approach is to save the values of your first and second column (the columns you want to sort your values with) in ArrayLists and then use dynamic variables to save the actual content. Look at the following code. It should be able to display the information
you need.
#Specify the path of the excel file
$FilePath = 'Path\file.xlsx'
#Specify the Sheet name
$SheetName = "Sheet"
# Create an Object Excel.Application using Com interface
$objExcel = New-Object -ComObject Excel.Application
# Disable the 'visible' property so the document won't open in excel
$objExcel.Visible = $false
# Open the Excel file and save it in $WorkBook
$WorkBook = $objExcel.Workbooks.Open($FilePath)
# Load the WorkSheet 'BuildSpecs'
$WorkSheet = $objExcel.sheets.item($SheetName)
# I am taking row count as 2, because the first row in my case is header
$intRow = 2
[System.Collections.ArrayList]$farr = @()
[System.Collections.ArrayList]$sarr = @()
Do {
# Reading the first column of the current row
$First = $WorkSheet.Cells.Item($intRow, 1).Value()
# Reading the second column of the current row
$Second = $WorkSheet.Cells.Item($intRow, 2).Value()
# Reading the third column of the current row
$Third = $WorkSheet.Cells.Item($intRow, 3).Value()
"First: " + $First
"Second: " + $Second
"Third :" + $Third
if($farr -notcontains $First){
$farr.Add($First)
if($sarr -notcontains $Second){
$sarr.Add($Second)
$variable = Get-Variable -Name "$First-$Second" -Scope Global -ErrorAction SilentlyContinue
if ($variable -eq $null)
Write-Host "$First-$Second does not exist"
New-Variable -Name "$First-$Second" -Value $Third
else{
$val = Get-Variable -Name "$First-$Second" -ValueOnly
Set-Variable -Name "$First-$Second" -Value $val","$Third
$intRow++
}While ($WorkSheet.Cells.Item($intRow,1).Value() -ne $null)
foreach($dec in $farr){
foreach($city in $sarr){
$variable = Get-Variable -Name "$dec-$city" -Scope Global -ErrorAction SilentlyContinue
if ($variable -ne $null){
$dec+"--"+$city+"--"+$variable.Value;
my sample data looks like this
col1 | col2 | col3
abc | qwe | poi
abc | jhg | dfg
de | wer | rew
de | iuz | mnb
abc | qwe | iop
de | wer | asd
Regards,
Hristo Valev
Developer-Hotline for MSDN Online Germany
Disclaimer:
Please take into consideration, that further inquiries cannot or will be answered with delay.
For further information please contact us per telephone through the MSDN-Entwickler-Hotline:
http://www.msdn-online.de/Hotline
For this post by the MSDN-Entwickler-Hotline the following terms and conditions apply:
Trademarks,
Privacy
as well as the separate
terms of use for the MSDN-Entwickler-Hotline. -
Need Power shell script to run on all databases.
Hi,
I have a stored procedure to generate report, using power shell script want to get all databases, run stored procedure on each database and generate the results as .csv file, output the file with database name (place it on directory) and email .csv
file.
looking for script, can any one help pls?
Naveen| Press Yes if the post is useful.Can you please share with me the codes
Naveen| Press Yes if the post is useful.
Dear N_14
You can have a look on the followings
http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07
http://www.codeproject.com/Articles/415732/Reading-and-Writing-CSV-Files-in-Csharp
https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx
Best Regards
mintssoul -
Trying to run program off network location using GPO with Power shell script.
Hello All,
Not much of a script writer. I am giving it a shot. My issue is that I need to run a application update across our network and I am trying to do it with as little hands on as possible. So I was planning to push a GPO with a power shell script in it
to run the program with elevated privileges.
Little background:
We are running on a domain and end users do not have admin rights.
The application is stored on a share on our network that is open to all domain users.
The installer user name and password is a temp one and will only be valid for the 30 min window when everyone logs in at the beginning of the day.
So this is what I have so far.
$username = "USER"
$password = "PASSWORD"
$credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDirectory \\Server\Folder\Folder1\Folder2\filder3\PSQLv11sp3_x32\
But for some reason I keep getting :
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:10 char:1
+ Start-Process PSQLv11Patch_Client_x86.msp -Credential ($credentials) -WorkingDir ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
Any help you could give would be great.
Thanks,
jdfmonkeyHi jdfmonkey,
Has anyone provided an answer to your original question? I am trying to use Start-Process to launch a process using another logged in user's credentials, and am not able to get it working:
$cred=Get-Credential
start-process Process.exe-WorkingDirectoryC:\Scripts-Credential$cred
I get the same error that you mentioned:
start-process : This command cannot be run due to the error: The system cannot find the file specified.
At C:\Scripts\Process.ps1:2 char:1
+ start-process Process.exe -WorkingDirectory C:\Scripts -Credential ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
When I leave off the credentials:
start-processProcess.exe-WorkingDirectoryC:\Scripts
It works correctly. Does anyone have a solution to make this work correctly?
Please ask your own question. You issue is nothing like the current thread. You clearly are using a user account that has no access to the folder. It is a permissions issue. It is not a scripting issue.
If you need further help please start your own question.
¯\_(ツ)_/¯ -
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,
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. -
Trying to run Power shell Script on task schedule
My case is i'm trying to run a power shell script through the task schedule.
Note if i run the script locally it is working fine but from the task schedule it is not working.
More information:
script function: Password Change Notification
Task name : test3
Time to do the task: 9:08 am every day
the status : running
.ps1 file location: under C\windows\system32\
some actions in the task history after the dated time to run:
1 Task Scheduler launched "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}" instance of task "\test3" due to a time trigger condition
2 Task Engine "S-1-5-21-60622444-1628707926-2526327935-500: enviroment\Admin:S4U:LUA" received a message from Task Scheduler service requesting to launch task "\test3" .
3 Task Scheduler started "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}" instance of the "\test3" task for user "enviroment\admin
4 Task Scheduler launched action ""C:\Windows\System32\Password Change Notification\Password Change Notification.ps1"" in instance "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}" of task "\test3
5 Task Scheduler launch task "\test3" , instance "C:\Windows\System32\notepad.exe" with process ID 5052Hi MeipoXu,
First of all i would like to thank you for your answer, i followed the URL that you posted already in the previous comment and unfortunately it didn't work, and please find my ps1 file
content as typed below and give me your feedback on that.
# # Version 1.1 May 2014
# Robert Pearman (WSSMB MVP) # TitleRequired.com
# Script to Automated Email Reminders when Users Passwords due to Expire.
# # Requires: Windows PowerShell Module for Active Directory
# # For assistance and ideas, visit the TechNet Gallery Q&A Page. http://gallery.technet.microsoft.com/Password-Expiry-Email-177c3e27/view/Discussions#content
# Please Configure the following variables....
$smtpServer="outlook. myDomain " $expireindays = 7
$from = "الدعم الفني
<ITHelpDesk@myDomain>"
$logging = "Enabled" # Set to Disabled to Disable Logging
$logFile = "PassExpireNotlog.csv" # ie. c:\mylog.csv
$testing = "Enabled" ## "Enabled" # Set to Disabled to Email Users
$testRecipient = "MyEmail@MyDomain"
$encoding = [System.Text.Encoding]::Unicode $date = Get-Date -format ddMMyyyy
# Check Logging Settings if (($logging) -eq "Enabled")
{ # Test Log File Path
$logfilePath = (Test-Path $logFile) if (($logFilePath) -ne "True")
{ # Create CSV File and Headers
New-Item $logfile -ItemType File
Add-Content $logfile "Date,Name,EmailAddress,DaystoExpire,ExpiresOn,MsgBody"
} } # End Logging Check
# Get Users From AD who are Enabled, Passwords Expire and are Not Currently Expired
Import-Module ActiveDirectory $users = get-aduser -filter * -SearchScope Subtree -SearchBase "OU=UsersOU,DC=MyDomain,DC=MyrootDomain,DC=MYrootNS" -properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet,
EmailAddress |where {$_.Enabled -eq "True"} | where { $_.PasswordNeverExpires -eq $false } | where { $_.passwordexpired -eq $false }
$maxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
# Process Each User for Password Expiry foreach ($user in $users)
{ $Name = (Get-ADUser $user | foreach { $_.Name})
$emailaddress = $user.emailaddress
$passwordSetDate = (get-aduser $user -properties * | foreach { $_.PasswordLastSet })
$PasswordPol = (Get-AduserResultantPasswordPolicy $user)
# Check for Fine Grained Password
if (($PasswordPol) -ne $null) {
$maxPasswordAge = ($PasswordPol).MaxPasswordAge
$expireson = $passwordsetdate + $maxPasswordAge
$today = (get-date) $daystoexpire = (New-TimeSpan -Start $today -End $Expireson).Days
# Set Greeting based on Number of Days to Expiry.
# Check Number of Days to Expiry
$messageDays = $daystoexpire if (($messageDays) -ge "2")
{ $messageDays = "خلال
" + "$daystoexpire" + " ايام"
} elseif (($messageDays) -eq "2")
{ $messageDays = "خلال يومين
} else
{ $messageDays = "اليوم."
} # Email Subject Set Here
$subject="كلمة المرور الخاصة بك ستنتهي
$messageDays"
# Email Body Set Here, Note You can use HTML, including Images.
$body = "<P style='font-family: Arial; font-size: 16pt' />
<center> الاستاذ/ $name
</center>
<br> <center>
كلمة المرور الخاصة بك ستنتهي $messageDays </center>
<br> <center>
نأمل تغييرها في أقرب فرصة حتي تتمكن من الدخول على النظام
</center>
<br> <center>
مع تحيات الادارة العامة لتقنية المعلومات
</center>
<br> </P>"
# If Testing Is Enabled - Email Administrator
if (($testing) -eq "Enabled")
{ $emailaddress = $testRecipient
} # End Testing # If a user has no email address listed
if (($emailaddress) -eq $null)
{ $emailaddress = $testRecipient
}# End No Valid Email # Send Email Message
if (($daystoexpire -ge "0") -and ($daystoexpire -lt $expireindays))
{ # If Logging is Enabled Log Details
if (($logging) -eq "Enabled")
{ Add-Content $logfile "$date,$Name,$emailaddress,$daystoExpire,$expireson,$body"
} # Send Email Message
Send-Mailmessage -smtpServer $smtpServer -from $from -to $emailaddress -subject $subject -body $body -bodyasHTML -priority High -Encoding $encoding
} # End Send Message
} # End User Processing
# End -
How to execute power shell script file inside DSC script resource
Hi,
How to execute /call powershell scirpt file inside DSC script resource , some thing like below and capture the status of execution.
Node $AllNodes.NodeName
Script ExecuteSQLDeploy
#SetScript = {powershell.exe .\SQLDeploy.ps1 "param1" "param2" "param3" "param4" "param5" }
#TestScript= {powershell.exe .\SQLDeploy.ps1 "param1" "param2" "param3" "param4" "param5 }
#GetScript= { return $true;}
BasawarajThanks for reply.
Now i am able to execute the power shell script with DSC. I am getting no error when i run , but the script logic wrote inside ( deploying sql incremental changes ) not working . I am using SQLCMD in the powershell script to deploy sql
changes . Can you please elaborate on "script is compatible with DSC" , the script
should not contain write-host cmdlet.... etc something like that.
Copying recursively from ****************************** to ************************** succeeded.
Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
An LCM method call arrived from computer ************ with user sid **********************************************
[V-BAKANT]: LCM: [ Start Set ]
[V-BAKANT]: LCM: [ Start Resource ] [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM: [ Start Test ] [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM: [ End Test ] [[Script]ExecuteSQLDeploy] in 0.1110 seconds.
[V-BAKANT]: LCM: [ Start Set ] [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM: [ End Set ] [[Script]ExecuteSQLDeploy] in 0.3010 seconds.
[V-BAKANT]: LCM: [ End Resource ] [[Script]ExecuteSQLDeploy]
[V-BAKANT]: LCM: [ End Set ]
[V-BAKANT]: LCM: [ End Set ] in 0.8810 seconds.
Operation 'Invoke CimMethod' complete.
Time taken for configuration job to complete is 0.923 seconds
Basawaraj -
Intermittent "Power Shell Script failed to run" after installing SQL MP 6.5.4.0
We recently installed the SQL MP. One thing I am struggling with is this "Power Shell Script failed to run" that occasionally comes up, but, not always on the same server, and not always at the same time.
It says it ran past the configured timeout of 300 seconds.
The post that seemed to have me on the right track was
https://social.technet.microsoft.com/Forums/en-US/c539a55d-dd48-438f-b7d5-06ed2cecf6e9/powershell-script-failed-to-run-alerts-from-sql-management-pack-6410?forum=operationsmanagergeneral
However, even after getting one of the several scripts that have been generating the error, out of the extract management pack, it has parameters that need to be fed to it that I have no idea what they are....
Example. ActiveRequestsDataSource.ps1 requires $computername, $connectionstring, $tcpport, $sql_wmi_namespace, and $servicename.
The computername is easy enough... so is tcpport. but, the others... not so much.
I am fairly certain I will be able to run these manually, if I just knew the parameters... I am also fairly certain we are getting these because at the time of the check, resources on that server are tied up for one reason or another.
Can someone please help? This is killing me.Hi,
As this issue happens after you installing SQL MP, so from my point of view, it seems like caused by the runas account for the SQL MP is not configured well, I would like to suggest you follow the article below to configure runas account for the management
pack:
Configuring Run As Accounts and Profiles in OpsMgr – A SQL Management Pack Example
http://blogs.technet.com/b/kevinholman/archive/2010/09/08/configuring-run-as-accounts-and-profiles-in-r2-a-sql-management-pack-example.aspx
Regards,
Yan Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] -
Power shell script to run a Resuable workflow.
Hi,
We came across a scenario where we want to run a resuable workflow on all List items in a list. I am not sure if this can be acheived through power shell. Can any one please help me to run reusable workflows through power shell script on list items.
Thanks,
SandyHello,
Recently i executed below script for my VS workflow on list items, you can also try same on reusable WF.
Basically you need to use "WorkFlowManager" and "WorkFlowAssociations " to find WF on list and then execute it.
http://www.mysharepointadventures.com/2012/06/start-a-workflow-using-powershell/
http://www.thesysadminhimself.com/2013/09/sharepoint-start-workflow-all-items-powershell.html
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Add workflow to contenttype by share-point power shell script
Hello,
I need to add work flow "Publish Approval" to content type by SharePoint power shell script .
how Can I implement that ?
ASkHi,
According to your post, my understanding is that you want to add the workflow to a content type using PowerShell script.
The following PowerShell script for your reference:
function AddWorkflowToContentType($site, $ctName, $WfName, $WfAssociationName, $TaxTaskList)
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SharePoint')
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.Office.Policy')
[Guid]$wfTemplateId = New-Object Guid
$web = $site.RootWeb
$ct = $web.ContentTypes[$ctName]
$culture = New-Object System.Globalization.CultureInfo("en-US")
$template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
if($template -ne $null)
$tasklist = $TaxTaskList
$historylist = "IP Workflow History"
# Workflow Association with Content Type
$association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateSiteContentTypeAssociation($template, $WfAssociationName, $web.Lists[$tasklist], $web.Lists[$historylist])
$association.AllowManual = $false
$association.AutoStartCreate = $true
$ct.AddWorkflowAssociation($association)
$ct.UpdateWorkflowAssociationsOnChildren($true, $true, $true, $false)
$association.Enabled=$true
$ct.Update()
$web.Update()
else
Write-Error "Workflow Template not found"
Add-Content $logFileName "Workflow Template not found."
More information is here:
http://anujabhojani.blogspot.com/2013/04/powershell-to-attach-workflow-on.html
Best Regards
Dennis Guo
TechNet Community Support -
HOW TO RUN POWER SHELL SCRIPT UNDER SAFE MODE
hi
is is possible to run the power shell script (with Management instrument code ) in safe mode
if so then how to do it, please explain the procedureHi CHELLAPPA,
Based on my research, we can use powershell in safe mode, and I also tested on server 2012 R2:
You can also open cmd and type "powershell" to use powershell script.
If there is anything else, please feel free to post back.
Best Regards,
Anna Wang -
Power Shell Script to Initiate Billing Determinants Calculations
Hi All,
I'm New to CC&B, i have a problem when i try to initiate the BD Calc thru Power shell script for "ALL" Accounts, at the same time i'm able to succeed for single account. Did any one faced this problem ?
Any advise?
btw, i use Win2008R2 server (x64) | MDM 1.6.1.2 | PShell v1.0
- Nandawbadmin start systemstatebackup -backupTarget:$backdir -[quiet]"[quiet]"? I guess you should remove the bracketswbadmin start systemstatebackup -backupTarget:$backdir -quiet
-
Web Service to call Power Shell Script
Hello All,
How can we make a call to power shell script from a asp.net web service with parameter ?
Thanks in AdvanceNormally you can do everything using web service, why do you want to call powershell
May be you can plan
http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx
Plan to use workflow for same
http://ilovesharepoint.codeplex.com/wikipage?title=Execute%20PowerShell%20Script%20Action
Also check
http://forums.iis.net/t/1161083.aspx?running+PS+scripts+from+a+webpage+sharepoint+site
If this helped you resolve your issue, please mark it Answered
Maybe you are looking for
-
Jump from alv report to FB03 screen when u click BELNR field
Hi experts, I developed one alv report in that one field is there (BELNR .When u click on BELNR field it will directly go to FB03 screen. I wrote in this way. FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD CASE SELFIELD-
-
Wondering if anyone has ever had the following problems and how to resolve them. e-mail app wont open, just crashes instantly, imessages and texts wont send or receive, pictures wont delete and are showing up all fuzzy, when i take a picture it show
-
ITunes won't open, says files are missing. reinstall?
I've been using iTunes for a couple years now today I can't open it. A message keeps popping up saying I need to reinstall iTunes due to files missing. Is there a way to do a "repair install" What do I need to do to not loose all of my music.
-
Determining the last archive applied on Logical Standby
Hi, I am trying to determine the last log received and applied on my Logical Standby SQL> select thread#, max(sequence#) "Last Standby Seq Received" from v$archived_log val, v$database vdb where val.resetlogs_change# = vdb.resetlogs_change# group by
-
UDO forms doesn't display after export
Hi Guys! I've created an add-on from my PC and works well. I did a backup of my database with UDO forms etc. and transfer them into another server. When I clicked the menu for the UDO, the form doesn't appear. Is there any files or procedure I had mi