How to roll back power shell scripts
if i am run any scripts on the power shell and after that there is a problem then i need to roll back that scripts.
Abp
You should be very comfortable with a scripting language before you should run them in production. If you are comfortable with PowerShell then you know exactly what that script will execute. You should have a backup solution, but you could also use PowerShell
to export and import configurations in certain cases as a way to backup/restore settings. If you are learning PowerShell and you are executing cmdlets you can make good use of the -WhatIf parameter.
http://blogs.technet.com/b/heyscriptingguy/archive/2011/11/21/make-a-simple-change-to-powershell-to-prevent-accidents.aspx
http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/08/weekend-scripter-easily-add-whatif-support-to-your-powershell-functions.aspx
Hope this helps.
http://mariusene.wordpress.com/
Similar Messages
-
Hi,
Let say, I have 3 parameters.
1. Script FolderPath (Remote path for e.g \\RD101\ScriptSharedFolder Here RD101 is one server)
2. Script Name(StopAllService.ps1)
3. Server Name (RD45)
I want to execute a powershell scritp in my local machine(Test1) and in that script I want to pass the above three parameters.Now I want to excute the StopAllService.ps1 script into RD45 server. But the script is available in RD101 machine.
So What I want to here How can we do this ? I have script name and script folder path and target execution server name.
Pls giude me or give me the script.
By
A Path Finder..
JoSwa
If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"
Best Online JournalHi,
You got 2 solutions for your problem:
1- If you have permission to run scripts in the remote computer without specifying your credential,
then, the first reply solve your problem.
2- If you have permission to run scripts in the remote computer
having to specify your credential, l then,
my solution solves your problem.
If the remote computer requires signed scripts only, you need signed script. Period. Or are you trying to break remote computer security?
If you need signed script, there's no psdrive that'll circumvent such requirement.
The problem is that the execution policy is set to "RemoteSigned". Using the URL explicitly tags that script as being from a remote source, and the policy blocks it. The PSDrive provides a local reference for the script. It does not
sign the script but the local drive reference may prevent it from being blocked for being from a remote source. I'll test that later.
Script signing is not and should never be considered a security measure. It is easily circumvented by running the script using powershell.exe, and using the -ExecutionPolicy parameter to override whatever the local execution policy setting is.
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " " -
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 -
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. -
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 -
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 -
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 -
Can any one tell me how can i call a shell script from pl/sql
i like to call shell script from pl/sql procedure.
can any one suggest how can i do thisHave you not mastered in asking the same kind of question ?
First do write a script...
no one will spoon feed you.
How can i call a shell script from procedure
How to call Shell Script from pl/sql block
-Sk -
How can i call a shell script from procedure
I have a shell script.now i am i a situation to call that shell script from one of my procedures and need to get a value from that script.
can u suggest me that how can a call the shell script from pl/sql?Is the same question you asked here
How to call Shell Script from pl/sql block
-SK -
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.
¯\_(ツ)_/¯ -
How to roll back changes made by other user in nwdi?
hi all
my doubt is.
if there are errors in the WD NWDI project (cause developer before me had deleted/ added some of the code which is causing those errors).
how to roll back the code changes which were made by other user.
i think through sync option but when we sync to a earlier date we cant check out the code to make changes.
help me.thanks rohit.
but if there are changes in the context, i mean if one more attribute is created and it is been used a UI element.
then the above process works.
My doubt is.
src folder(configuration,packages,mimes)
Will these file contain all the code including the context attributes and the mapping informatin and every thing else.
(except Libs)???????
can you plz tell me where the context attributes and mapping informantion and source code and model information are stored (in which folder).
thanks in advance -
How to roll back when procedure fails
Hi All,
In my process using procedures i am droping the temp tables and creating temp tables ,if any procedures fails how should roll back all the process
Procedure1(droping tables)----->procedure2(creating table1)--------->procedure3(creating table2)------->procedure4(Validaating accounts in table2 and creating seperate table)
Any suggestion please
Thanks in AdvanceLet's say in your package you have your 4 procedures (Proc1, Proc2, Proc3, Proc4).
Also create 3 additional procedures:
RollBack1 -> Does the opposite to Proc1 (i.e. if Proc1 drops a table, then Rollback1 will create it)
RollBack2 -> Does the opposite to Proc2
RollBack3 -> Does the opposite to Proc3
Your logic will be:
If Proc1 is successful, then execute Proc2.
If Proc1 is unsuccessful, then end.
If Proc2 is successful, then execute Proc3.
If Proc2 is unsuccessful, then use an on failure path (red line) to execute RollBack1.
If Proc3 is successful, then execute Proc4.
If Proc3 is unsuccessful, then use an on failure path (red line) to execute RollBack2, followed by RollBack1.
If Proc4 is successful, then end.
If Proc4 is unsuccessful, then use an on failure path (red line) to execute RollBack3, followed by RollBack2, followed by RollBack1.
It mightn't be necessary to undo everything - but you'll know your own business needs to make a decision on that. -
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 -
Hi Experts,
We are investigating if any SAP customer that implemented SAP APO PPDS has ever attempted to establish a "roll back" of the SAP APO PPDS created supply plan to a defined point before the start of the SAP APO PPDS planning batch run?
We have a situation where - in the middle of the planning batch run - randomly or intermittent the batch run hangs or runs a step for multiple hours that normally, at most days, takes only a few minutes to run. In a situation like this, the supply plan is not in a state where customer sales orders can be promised (using GATP CTP) or planned orders can be converted to production orders and published to SAP ECC, etc since the plan may be capacity infeasible or simply partial or incomplete. To not hold the business operations hostage to wait resuming operations (promise customer sales orders, convert and release and execute orders to transfer, deliver, produce, or purchase) for hours or days, we need to find a way back to the original plan right before the nightly PPDS batch planning job started.
We already close all the queues from ECC to APO, thus, no CIF traffic from ECC to APO. We also shut down the customer sales order feed into ECC as normal process for duration of the APO PPDS batch planning run. Thus, functionally, we are theoretically in a situation to simply go back to a PPDS and active planning version save prior to the run. Yet, many more technical and BASIS-related questions remain on how to roll back to a state where the plan was not compromised.
This inquiry is to learn if any other SAP customer has ever established a process to roll back SAP APO PPDS to a previous point in time supply plan to resume operations? Whatever the reasons are, be it after a failed batch run, or any time during the normal interactive plan day.
Additional information about our design and plan:
1. We have a two year horizon supply plan in PPDS
2. We only publish to ECC 14 days worth of planned orders, stock transfer requirements, and purchase requirements
3. We convert planned orders to production orders and release production orders in ECC 2 days before first operation starts
4. We convert PR's to PO's and STR's to STO's in ECC 2 days before execution (ship or submit to vendor)
Any indication where a SAP customer has developed and uses a process to roll back an SAP APO PPDS- planned supply plan to an earlier point in time or version would be helpful to know.
Regards,
Manimaran M.Hi Manimaran,
Saving in Simulation means in DS board when you click on save it provides you option to save sim version or adopt to active version. If you copy to inactive version you cannot copy back trasaction data specially PPDs orders back to active version again while if you save in simulation you can adope it to active version at any point of time. YOu can adopt simulation version changes to active version using T-code /SAPAPO/CDPSS0
Copying to active version means you copy data from version 000 to some other active version while here results are kept simulation,
Maybe you are looking for
-
Adobe Premiere CS3 keeps crashing everytime I attempt to export to Encore
Hey folks, As the title suggests, everytime I try to export my project onto the Adobe Encore CS3 programme it crashes, with the message "sorry, a serious error has occurred that requires Adobe Premiere Pro to shut down. We will attempt to save your p
-
Error while converting planned order to production order for config materia
Hi experts, While converting a planned order to production order for a configurable material.I am getting the following error meassage. Message No.CO684, "You cannot make an assignment to make-to-order stock" ( DiagnosisThe component cannot be alloca
-
Acrobat 8 Pro not compatible with Win 7 Pro 64
When I changed from Win XP Pro to Win 7 Pro I could not transfer Acrobat 8 Pro. Adobe Support just informed me that Acrobat 8 Pro was not designed for Win 7 and that's it. This was pretty frustrating and gave me the opportunity to search the market.
-
Photo Stream not working on the Mac
Photo Stream is working on my iPhone, iPad and MBP but can not get to work on my iMac. Everything is turned on. Any suggestions?
-
Open to specific page in pdf not working in IE
IE 9 Dear all, The URL page parameter isn't working for me. I have tried adding #page=3 to my url. The pdf document however opens to the first page rather than the third. Any suggestions? Regards, MDB