#ScheduledTasks
Explore tagged Tumblr posts
virtualizationhowto · 11 months ago
Text
New Scheduled Task to Delete Snapshots in vSphere 8.0 Update 3
New Scheduled Task to Delete Snapshots in vSphere 8.0 Update 3 #vmware #vmwareautomation #vsphere8u3 #scheduledtask #deletesnapshots #snapshotsarenotbackups #vsphere8u3newfeatures #virtualization #homelab
In case you have not seen as of yet, one of the new features that is a welcomed addition to vSphere 8.0 Update 3 is a new built-in scheduled task feature that gets rid of snapshots on virtual machines. This is a great new feature that is built-in without having to jump through hoops with other tools or scripts. However, as we will see, the new task can also be extremely handy with PowerCLI and…
0 notes
sqlcan · 3 years ago
Text
Windows Task Scheduler for SQLOpsDB
Windows Task Scheduler for SQLOpsDB
The Windows Task Scheduler executes the PowerShell script for data collection for both SQLOpsDB data collection and configuration health. These collections can be completed via the SQL Agent jobs also, however, I chose to leverage the Windows task scheduler so jobs can be executed using gMSA. In the SQL Server, gMSA cannot be used as a proxy account. As stated in the previous posts, there are…
Tumblr media
View On WordPress
0 notes
ryadel · 7 years ago
Text
Windows - Auto-Reboot and shutdown with Task Scheduler
Tumblr media
Despite the common belief, the practice of programming a system reboot or shutdown of a client or server machine isn't necessarily a bad thing: in some limited scenario planning a regular shutdown or reboot of the operating system could be a decent workaround to securely put the machine in a desired state - for example, to make it ready for a VM-based backup or for installing a planned update. Depending on the situation, it could even be acceptable to setup a recurrent period - once a week, for example - to issue a system reboot.  The ideal interval, needless to say, might vary a lot depending on the features performed by our server, its service availability expectactions and other variables in play: if the server performs its activities only during daytime can probably be restarted every night without major issue, while a web server that serves sites or services troughout the world should be restarted only in exceptional circumstances. It's also worth noting that you can often get the same benefits by recycling the Application Pools or other resource-heavy processes, as we'll see in a short while. Setting up our machines to reboot at regular intervals could also be useful to ensure that the system will be able to get back on track in case of a planned reboot - such as those issued by system updates or due to unforeseen situations - service interruption, power failure, hardware failure and other more or less serious events that could always happen. Since the ability to recover after those unexpected events is the fundamental premise of any Disaster Recovery procedure, setting a reboot at regular intervals might also be a not-so-terrible way to periodically test our system against these kind of threats. To set up an automatic system restart, open the Control Panel (if you do not know how to do on Windows 10, read here) and open the Task Scheduler in the following way, depending on your version of Windows: Windows 2000/XP, Windows Server 2003 and previous versions/builds: select the Task Scheduler (or Scheduled Tasks) icon. Windows Vista, Windows 7/8/8.1/10, Windows Server 2008 and newer versions: open the Administrative Tools folder, then select the Task Scheduler icon.
Tumblr media
Once the Task Scheduler window is open, create a new task using the  Create Task action in the following way:
Tumblr media
A modal window will be opened: use the General tab to setup a name and a description to the new task. Other than that, it can be useful to properly setup the following options: Run whether user is logged on or not, to ensure that the task will be executed even if there are no logged-in users. Run with highest privileges, to make sure that the task will be executed with administrator rights - this is required for issuing a system hutdown or a reboot.
Tumblr media
For further info regarding the other options, check out this MS TechNet article. Once done, move to the Trigger tab and click on the New button to create an execution trigger - which is, the event that will make the system run the task itself. A New Trigger modal window will then be opened, which you can use to setup such event. The most common trigger to setup here is a time-based trigger, which can be set by selecting the On a schedule option on the Begin the task dropdown list:
Tumblr media
Il trigger che abbiamo creato eseguirà l'attività ogni notte alle ore 04:00. For further info regarding triggers, take a look at this MS TechNet page. Once done, move to the Actions tab and click to the New button to setup the command to execute whenever the trigger fires. Setup an automatic Shutdown (without reboot) Setup an automatic Reboot Here's a brief explanation of the parameters used above: -s : setup the automatic shutdown of the system without a reboot. Alternative to the -r option (see below). -r : setup the automatic reboot of the system: this option is required to ensure that your system will actually restart. Alternative to the -s option (see above). -f : ensure that all the processes and services will be gracefully closes and/or stopped before performing the shutdown or reboot: this is a required option to ensure a clean and graceful shutdown. -t : setup a timeout before executing the shutdown or reboot (in seconds): the default is 20 (20 seconds), but can be changed by adding a number right after it, separated by a space: for example, -t 50 for 50 seconds. This option is great to use because it will also show a warning popup to logged-in users (if there are any) when the shutdown/reboot time occurs, allowing them to close their tasks and log out. For a detailed explanation of all the shutdown.exe options and parameters, you can take a look at this official MS TechNet doc. As soon as you define the Action, your planned activity should be ready: take a few seconds to check all the settings once again, then click OK to create the task. If you asked to run the task with elevated privileges the system will ask you to enter the credentials of the Administrator account (or the account with administrative privileges you have chosen in the General tab): once done, the result of your work will appear, summarized in a single line, within the Task Scheduler main panel:
Tumblr media
Un esempio del pannello "Actions" del Task Scheduler di Windows 8. A good thing to do before closing everything is to run the task immediately to prove it works (right mouse button -> Run): alternatively, you can just wait for it to occur automatically at the time you have set and then check the Last Run Time / Last Run Result parameters to determine the outcome.
Conclusion
That's it for now: I hope that this small tutorial will help other System Administrator looking for a way to setup an automatic shutdown and/or reboot!   Read the full article
0 notes
ask-me-why-i · 7 years ago
Photo
Tumblr media
Decided to do a timeline of my typical day. Skipping a few things, like my morning meditation (6am) and feeding the cat (6:15). Let’s get into rinsing the cans to take to recycling and breakfast! (6:30-7) #timeline #scheduledtasks #dietcoke #idontdrinksodaguys #chorizoconpapas #icheatedandusedcornedbeefhash #amistillmexican #welldressedstressedandclinicallydepressed
0 notes
tech-battery · 5 years ago
Text
Windows 10 update created a major password problem
Microsoft has detailed a temporary fix for a frustrating Windows 10 bug that prevents software from storing account credentials, meaning the user has to re-enter their username and password each time they log-in.
The flaw is also said to delete cookies held in web browsers, preventing websites from memorizing credentials and serving bespoke content to the user.
First reported in April, the issue is present in specific builds of Windows 10 version 2004 and affects applications such as Outlook, Chrome, Edge, OneDrive and more.
Windows 10 passwords issue
Although users have struggled with the Windows 10 issue for months now, Microsoft has only recently acknowledged the issue in an official capacity in the form of a support notice.
“After installing Windows 10 Version 2004 Build 19041.173 and related updates you will find that Outlook and other applications do not remember your password anymore,” explained the firm.
“The issue occurs when some Windows 10 Task Scheduler tasks are configured in a certain way. Until a fix is available, a workaround is to disable these tasks using Task Scheduler.”
To implement the temporary fix, right-click the Start Menu, select Windows PowerShell (Admin) and enter the following command:
“Get-ScheduledTask | foreach { If (([xml](Export-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath)).GetElementsByTagName("LogonType").'#text' -eq "S4U") { $_.TaskName } }”
If any tasks are listed in the PowerShell window, note them down and launch the Task Scheduler app. Once you’ve located the relevant tasks, disable them via the right-click drop-down menu. Restarting the affected device should then resolve the issue.
It is not clear at this stage when Microsoft will roll out a full fix for the problem.
0 notes
leistung-akku · 5 years ago
Text
Windows 10: Bug sorgt für Probleme mit Cookies, Workaround verfügbar
Obwohl Microsoft fortlaufend daran arbeitet, das eigene Betriebssystem Windows 10 zu verbessern, tauchen in den Updates immer wieder neue Bugs auf. Einige Nutzer der Version 2004 sollen Probleme damit haben, dass Cookies und Anmelde-Daten nicht richtig gespeichert werden.
Das Windows 10 Mai 2020 Update (Version 2004) und die darauffolgenden kumulativen Aktualisierungen scheinen bei einigen Nutzern dafür zu sorgen, dass die Cookies in Browsern wie Chrome und Edge nicht mehr erfasst werden. Nach einem Neustart des Computers sind die Nutzer auf vielen Seiten ausgeloggt. Der Bug soll Windows Latest (via Deskmodder) zufolge auch zahlreiche Apps, welche die Anmelde-Daten des Nutzers speichern, betreffen.
Fehler ist bereits seit Mai bekannt
Die Fehler treten bereits seit Mai auf und schei­nen in den letzten Wochen bei immer mehr Nutzern zum Vorschein zu kommen. Vor kur­zem hat Microsoft dann bestätigt, dass der Bug bekannt sei und man an einer Lösung arbeite.
Ein Nutzer hat nun herausgefunden, dass für die Probleme ein Fehler in Zusammenhang mit der Aufgabenplanung verantwortlich zu sein scheint. Die Aufgabe "TASK_LOGON_S4U" ist dafür zuständig, einen Prozess im Namen eines Nutzers auszuführen, ohne das Kennwort spei­chern zu müssen. In manchen Fällen werden die Informationen allerdings nicht kor­rekt über­ge­ben, sodass Cookies und weitere App-Daten nicht mit dem Nutzerkonto verknüpft werden und nach dem Abmelden verloren gehen.
Nutzer können einen Workaround verwenden
Wer nicht warten kann oder möchte, bis Microsoft einen offiziellen Patch zur Verfügung stellt, kann auf einen einfachen Workaround zurückgreifen. Hierfür muss zunächst die PowerShell geöffnet werden. Anschließend wird der Befehl
Get-ScheduledTask | foreach { If (([xml](Export-ScheduledTask -TaskName $_.TaskName -TaskPath $_.TaskPath)).GetElementsByTagName("LogonType").'#text' -eq "S4U") { $_.TaskName } }
eingegeben. Nun muss der Nutzer die Aufgabenplanung starten und alle mit dem Kommando aufgelisteten Aufgaben deaktivieren oder auf 'Run only when user is logged on' setzen. Nach einem abschließenden Neustart des Computers sollte es keine Probleme mehr geben.
0 notes
activedirectoryfaq · 5 years ago
Text
Create Multiple Scheduled Tasks with PowerShell
The more parameters are added, the more complex the manual creation of automatic timed-controlled tasks in Windows are. In the first part of my blog posting, I showed how to use the Windows Task Scheduler to run PowerShell scripts at specific times. 
Read the full Article https://activedirectoryfaq.com/2020/05/create-multiple-scheduled-tasks-with-powershell/
#CreateTask, #NewScheduledTask, #Powershell, #WindowsTaskScheduler
0 notes
peterandersonaj · 5 years ago
Text
Fix: K-12 Assessment Reports Apps Running in Windows 10 Background
Windows 10 users have been facing the K-12 assessments running in the system background. Developed by the AIR Secure Browser the unauthorized application might be running in your device background too. With this, you cannot start any assessment or log out from any running assessment, so you need to end all the running applications in the background manually through the Task Manager. In this blog, we will teach you how you can check the issue and resolve the problem with K-12 assessment errors in your application like Microsoft Edge and Microsoft Photos running in Windows 10.
Tumblr media
Here are the keys terms that are used in this blog:-
K-12
K-12 is a term especially used in education and educational technology in the US, Canada, India, Egypt, South Korea, Philippine, and Turkey. It is a short form for public support like prior collage and school grade. The grade is shown as K (Kindergarten) and starts from 1st to 12th grade when the term counts as 13th grade, which means you are in the first year of college.
K- 12 Assessment
It is an accountable format and SA (Summative assessment) that is a part of the examination for the students who are learning at the end of the year. It provides students to result in the grading system and allows the student to the district to measure how they well learning and teaching required for the students as well as a teacher too.
The AIR Secure Browser
The AIR secure browser is an application for the American Institutes and Research that takes online testing of the student experience and making an assessment with the PC Google Chrome. If you want to maintain top-level security, then you need an AIR Secure test browser and Google Chrome book to do this process.
Here is the Take a Test application in the Windows 10 that create several right environments for taking as follow:-
§  Take a Test clean the clipboard.
§  Students cannot change settings, see notifications, extend their display, or auto-fill features and get updates.
§  Students cannot start or access other applications.
§  Cortana is switched off.
§  Students cannot share, print, save screens unless enabled by the IT administrator or teacher.
§  Students cannot go to other websites.
§  Take a Test shows and nothing else in the application.
 K-12 Assessment Found Unauthorized Application Running in the Background
This problem occur because of AIR assessment that is several applications that not allowed running application on the running background.
1) When Windows protector application temporarily disable than follow the given command:-
Stop-Service -Name hvsics -ErrorAction SilentlyContinue                            
2) Disable app prelaunch:-
Disable-MMAgent -ApplicationPreLaunch
3) reset Windows protector application guide:-
Start-Service -Name hvsics -ErrorAction SilentlyContinue
4) Disable Prelaunch of Microsoft Edge by setting registry key:-
$registryPath = “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\PreLaunch\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge”
$Name = “Enabled”
$value = “0”
New-Item -Path $registryPath -Force | Out-Null
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force | Out-Null
5)Create scheduled task to enable application prelaunch:-
$A = New-ScheduledTaskAction -Execute “powershell” -Argument “-Command `”Stop-Service -Name hvsics -ErrorAction SilentlyContinue; Enable-MMAgent -ApplicationPreLaunch;Start-Service -Name hvsics -ErrorAction SilentlyContinue;New-ItemProperty -Path `”HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\PreLaunch\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge`” -Name `”Enabled`” -Value `”1`” -PropertyType DWORD -Force | Out-Null`””
$revertDate = <Specify a date>
$T = New-ScheduledTaskTrigger -Once -At $revertDate
$P = New-ScheduledTaskPrincipal -UserID “NT AUTHORITY\SYSTEM” -LogonType ServiceAccount -RunLevel Highest
$timespan = New-TimeSpan -Minutes 1
$S = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -StartWhenAvailable -RestartCount 3 -RestartInterval $timespan
$D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S
Register-ScheduledTask DisableAppPrelaunch -InputObject $D
 Conclusion The issue is not a life-threating one, but it can severley hinder your work progress. Therefore, it is suggested that you follow the instructions carefully and implement them properly.
  Harry Williams is an inventive person who has been doing intensive research in particular topics and writing blogs and articles on webroot.com/safe and many other related topics. He is a very knowledgeable person with lots of experience.
Source : K-12 Assessment Reports
0 notes
inthetechpit · 7 years ago
Text
Enable disable Windows Service and Scheduled Tasks with PowerShell
Enable disable Windows Service and Scheduled Tasks with PowerShell
Often we may need to enable/disable Windows Services and Scheduled tasks on a Windows Server.
Below is the snippet to Enable Windows Service and Scheduled task with PowerShell:
$tasknames = "Test Task1","Test task2" $servicename = "Test Service1","Test Service2" foreach($task in $tasknames) { ##disabling tasks on server $taskstatus = Get-ScheduledTask -TaskName $task if($taskstatus.State…
View On WordPress
0 notes
virtualizationhowto · 1 year ago
Text
Three Simple Things to Make VMware ESXi More Secure
Three Simple Things to Make VMware ESXi More Secure @vexpert #vmwarecommunities #vmwaresecurity #ntp #ssh #vmwaretools #automation #virtualization #vhtforums #virtualmachines #vms #vmwareesxi #powercli #cicd #scheduledtask #configurationmanagement
If you are like me in production and home lab environments, I am always looking for low-hanging fruit to make things better, faster, more efficient, and more secure. There are three things that you can do in VMware ESXi to make your environment more secure. Let’s dive into what those are and how you can easily implement these using a PowerCLI script run from a scheduled task or even a CI/CD…
Tumblr media
View On WordPress
0 notes
peterbowey · 7 years ago
Text
New Post has been published on Peter Bowey Computer Solutions Blog
New Post has been published on https://www.peterboweycomputersolutions.com.au/blog/the-operation-of-automatic-maintenance-in-windows-10
The operation of Automatic Maintenance in Windows 10
Tumblr media
With Windows 10, automatic maintenance runs in the background whenever the computer becomes idle, including when you sleep, as long as there is power. By default the automatic maintenance checks for errors to fix (via Windows Error Report), performs hard drive storage optimization, system diagnostics and optimizes other services to [generally] improve the overall performance of your computer.
With Windows 10, the automatic maintenance feature was designed to help keep your computer healthy and optimize it without compromising performance or energy efficiency.
Normally, automatic system optimization occurs once a day at a time when you are not actively using the computer. If your computer is in Sleep mode, while on AC Power, it will be resumed and the maintenance events will be carried out using full system resources to execute the task as fast as it can. After completion of the automatic maintenance, the system will return to Sleep mode. However, it is possible to modify this schedule to avoid missing an automatic maintenance if your computer is turned off at critical times, or if something does not go as planned.
Automatic maintenance under Windows 10
Tumblr media Tumblr media
Windows 10 Automatic Maintenance
Automatic maintenance is a set of associated tasks, scheduled to run daily at 3:00 AM by default. These tasks run simultaneously in the background only when your computer is powered on and idle. In this case, Windows 10 is able to actively perform maintenance and then sleep (economize power consumption) once it is done.
During a typical maintenance operation, specific tasks will run; hard disk optimization and defragmentation, scans for Malware, attending to Action Center messages, system and application updates, security checks, system and device diagnostics, and other tasks that assist in keeping your computer healthy and functioning optimally. However, the number of tasks will differ among various computers as software developers use different devices and special applications may be added as tasks to the standard Windows 10 automatic maintenance scheduler list.
The optimization process can only run for one hour per day. If the tasks are not completed within this time, they stop and resume at the next scheduled event. An exception to this rule is the ant tasks marked as critical, these will continue to run until complete completion, even if you are actively using the computer.
You can manually start the Maintenance task immediately by clicking on the Run Maintenance button. This is referred to as the User Initiated Mode.
Tumblr media Tumblr media
Windows 10 Security & Manintenance Manual Mode
It should be noted that Windows 10 updates are more likely to download and install outside the normal maintenance schedule. You can not use the automatic maintenance feature to disable Windows Update.
In case your computer is turned off or if you are actively using it, the planned maintenance operation will be delivered at another time when these such tasks will impact you.
Scheduled Automatic Backups: File History
A important role of maintenance schedules is about how backups are done. Windows 10 offers a feature known as “File History”. File History is a simple but important utility that that backs up your important files and it works automatically – once it has been set up. File History is  not a complete backup of your whole disk drive, however it is a backup the  folders where you store documents, photos, videos, music, contacts etc. Basically everything that is important.
You can find File History in the Control Panel or in Windows Settings.
Tumblr media Tumblr media
File History – Windows Settings
Windows File History is typically set as off
Tumblr media Tumblr media
Windows File History is typicall Off
You need to add an external hard drive, USB flash drive, or some other external media storage.
Then File History can be enabled for the external media (any).
Tumblr media Tumblr media
Setup File History on External Media
Once you are ready to use that external media, you could click on “Advanced settings” and choose a time schedule for the File History and how long to keep saved versions.
File History will keep multiple versions of your files that often change and remove them after the set time period. If there is just one version of a file, it is left as is.
How to control automatic maintenance in Windows 10
Although maintenance works automatically under Windows 10, you can consider various aspects of automatic maintenance. Here’s how to do it:
To open automatic maintenance, you can search for its settings via Cortana or through the Control Panel.
Tumblr media Tumblr media
Windows 10 open automatic maintenance
Click the Maintenance section to bring up the automatic maintenance options
Click Change Maintenance Settings
Tumblr media Tumblr media
Windows 10 Change maintenance settings
Use the drop-down menu to choose the time you want the system to perform automated maintenance tasks.
Tumblr media Tumblr media
Windows Automatic Maintenance Set Schedule Time
Tip: If you do not want your computer to automatically wake up at night, disable the Allow Scheduled Maintenance option to interrupt the sleep of my computer at the scheduled time.
Click on the OK button
Once these steps are completed, your computer will run the maintenance daily, at the time you have chosen and for a maximum of one hour. Note that ff you do use your computer, Windows 10 will postpone this maintenance.
If you want to run maintenance immediately, you can click Start Maintenance . This will cause the maintenance to continue and continue even if you are actively using your computer.
How to disable automatic maintenance on Windows 10
Automatic maintenance is a useful feature and it is desirable to leave it on for your PC to work to its full potential. But if you notice problems, such as unexpected performance consequences, crashes, or other problems, you can disable this feature.
Warning: Changing the Windows registry is can be a risky operation unless it is done carefully. I recommend that you make a full backup of your computer beforehand.
Although there is no disabling option in the Windows 10 automatic maintenance settings, you can manually disable it by editing the registry. Here are the steps to follow:
Use the Windows + R shortcut keys to open the Run command
Type Regedit and click OK to open the registry
Follow this part of registry tree: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance
Tip: On Windows 10 Creators Update and later, you can copy / paste the path into the new address bar of the registry to access the destination key directly.
Right-click Maintenance , select New and click 32-bit DWORD Value
Tumblr media Tumblr media
Edit Windows Registry – Add new 32-bit DWORD
Name the key MaintenanceDisabled and press Enter
Double-click on the newly created key and change the value from 0 to 1
Tumblr media Tumblr media
Windows Registry – New MaintenceDisabled Value
Click OK
Restart the computer.
Once these steps are completed, the Maintenance section and its options are still visible in the Control Panel, but the schedule will not run and if you click Start Maintenance , nothing will happen.
You can cancel changes at any time using the same instructions, then choose to delete MaintenanceDisabled with a right click and then choose Delete to clear it.
How to view all the Automatic Maintenance Tasks in Windows 10
Right mouse click over the Windows 10 Start tMenu and choose PowerShell Paste the command below into the PowerShell window
Get-ScheduledTask | ? $_.Settings.MaintenanceSettings | Out-GridView
Tumblr media Tumblr media
Showing all the Scheduled Tasks
In the result, you can see a list of all the scheduled maintenance tasks.
Although this guide is intended for Windows 10, you can use these instructions to manage automatic maintenance in Windows 8.1.
0 notes
chaitanya512-blog1 · 8 years ago
Text
fixeThe task XML contains a value which is incorrectly formatted or out of range Duration:P99999999DT23H59M59S
Hi All, When I am trying to create a scheduled task in windows server 2016, I was getting the below error. The task XML contains a value which is incorrectly formatted or out of range. (8,42):Duration:P99999999DT23H59M59S + CategoryInfo : NotSpecified: (PS_ScheduledTask:Root/Microsoft/.. .S_ScheduledTask) [Register-ScheduledTask], CimException + FullyQualifiedErrorId : HRESULT…
View On WordPress
0 notes
marcosplavsczyk · 8 years ago
Link
.polje { border: none; width: 300px !important; font-family:'Courier New'; font-weight: bold; }
ApexSQL Generate is a tool that can populate SQL databases with test data using multiple generators for each column. It supports a full range of SQL data types and has an ability to recognize them in a loaded SQL database and provide real-world test data based on contained data types. It can generate: randomized test data using the Random generator and various options, and using the Regular expression generator, sequential data using the Incremental generator, and much more.
To generate test data:
Run ApexSQL Generate
Select a built database from the Build step in the Database connection tab, of the New project window:
Once a database is set, click the Connect button in the bottom-corner of the New project window:
The application will load a database and show all tables and columns in the Results grid:
Select a database in the Results grid and set specific table options, from the menu on the right side, that can be applied to all tables in a database:
The Rows option allows to set the number of rows that will be generated for each table. This option can be also set for each table individually, by selecting a table and changing the number in the right-side menu.
If any error occurs during the data generation, the error handling option can be set to Stop generation or Skip row.
As mentioned, a built database could contain static data for some tables that were committed to the source control repository. In order to preserve that data, leave the Clear data option unchecked. To avoid any issues during the test data generation, disable triggers and constraints by using the options above.
In order to apply the set of options on tables, click the Apply settings button at the bottom and in the Apply settings window, choose tables on which you want to apply settings, move them to the right side with arrow buttons and click the OK button:
Since the data exist in some tables and not in others, it can be inserted by manually checking only tables that don’t contain data in the Results grid:
If there is a need to add test data to all tables, just leave all tables checked, as it is by default.
By default, ApexSQL Generate recognizes the column’s name and data type, and sets the most appropriate generator:
ApexSQL Generate allows choosing a different generator for each column. To choose a generator for a column, select a column and in the right-side menu, select a desired generator:
After each column generator is set, in the Test data preview pane, preview the generated data before executing or exporting:
Before starting the generation process, click the Save button, from the Home tab, and choose between the Save as (saving a project) or Save as batch file option:
By saving the project file, everything that was previously set in the current project will be saved in the project file and used for automating the process.
The other option is to use the batch file. If this options is chosen, in the Batch script preview, all previously set options will be expressed as CLI switches:
Check the Project settings option in the bottom-left corner, so that only checked tables are populated with test data.
After reviewing all option switches, click the Save button in the bottom-right corner and specify a location where to save it.
By saving the batch file, automating the process for the CI Populate step is much simpler, as less code is used in the PowerShell project.
To execute the generation process directly on a database, click the Generate button from the Home tab:
The Action plan window will be shown, with all actions that will be done on a database:
After reviewing the Action plan, click the Generate button in the bottom-right corner and the test data generation will be executed.
Once the generation and execution are done, the Post generation summary window will be shown:
Automating process using ApexSQL Generate and PowerShell
As previously mentioned, a 3rd party tool (in this case ApexSQL Generate) can be scheduled via a PowerShell project, in order to run it unattended.
In order to include the build step from the previous article in the automating process, so that the Build and Populate step are run in sequence, one after the other, i.e. once a database is built from the source control repository, it will be populated with static data. Also, there should be code for dropping the previously created database before each build step, in order to avoid any issues with building a database with the same name.
The best way is to schedule three tasks via PowerShell that will be run one after the other. The script for that kind of project will look like this:
Register-ScheduledTask ‘DeleteBuildTest’ -InputObject (New-ScheduledTask -Action ((New-ScheduledTaskAction –Execute ‘sqlcmd.exe’ -Argument ‘-S NINJA -E -Q “IF EXISTS(select * from sys.databases where name=”MyDatabase”) DROP DATABASE [MyDatabase]”‘),(New-ScheduledTaskAction –Execute ‘”C:\Program Files\ApexSQL\ApexSQLBuild2016\ApexSQLBuild.com”‘ -Argument ‘/pr:D:\BuildDB.axbd /v /f /out:”D:\outApexSQLBuild.txt”‘),(New-ScheduledTaskAction –Execute ‘”C:\Program Files\ApexSQL\ApexSQLGenerate2016\ApexSQLGenerate.com”‘ -Argument ‘/pr:D:\MyDatabase.axgn /v /f /out:”D:\outApexSQLGenerate.txt”‘)) –Trigger (New-ScheduledTaskTrigger -Once -At 7AM -RepetitionInterval (New-TimeSpan -Hours 1) -RepetitionDuration (New-TimeSpan -Days 365)))
Explanation of the code from the script:
Register –ScheduledTask ‘DeleteBuildTest’ # register a task and specify its name –InputObject # the input to this cmdlet –Action # a work item for a task to run. When multiple actions are specified, they are run sequentially –Execute ‘sqlcmd.exe’ # calls SQL CMD for execution –Argument # arguments for the command-line operation –S ServerName # SQL Server name –E # Windows authentication -Q “IF EXISTS(select * from sys.databases where name=”MyDatabase”) DROP DATABASE [MyDatabase]”‘), # SQL query that checks if a specified database exists and drops it –Execute ‘”ApexSQLBuild.com”‘ # calls ApexSQL Build application for execution. Application path should be provided and under double quotation marks /pr:”BuildDB.axbd” # the path for the ApexSQL Build project file /out:”outputApexSQLBuild.txt” # the path for ApexSQL Build’s output file –Execute ‘”ApexSQLGenerate.com”‘ # calls ApexSQL Generate application for execution. Application path should be provided and under double quotation marks /pr:”MyDatabase.axgn” # the path for the ApexSQL Generate project file /v # overwrites an existing file /f # prints all messages in console or output file /out:”outputApexSQLGenerate.txt” # the path for ApexSQL Generate’s output file –Trigger –Once –At 7AM # trigger starts a task once at a specified time with the –At parameter –RepetitionInterval (New-TimeSpan -Hours 1) # amount of time between each start of a task –RepetitionDuration (New-TimeSpan -Days 365))) # How long the repetition pattern will be repeated after the task is started
Note: Each application called by the -Execute parameter and all application switches after the -Argument parameter need to be under single quotation marks. Also, each path, including the application’s path, project file path, and output file path, need to be under double quotation marks.
For both tools, Windows authentication was used, but if SQL Server authentication is used, login password will be encrypted in the saved project file. If for some reason, this process need to be run attended, check out this article on how to handle database or login credentials.
During the execution of the PowerShell project, the following execution messages of ApexSQL Generate are shown:
Reading tables from database: MyDatabase Data generation started for database: “MyDatabase” Executing against database    Inserting data into table Person.Customer    Inserting data into table Person.CustomerAddress Execution successfully finished Total number of inserted rows: 200 Execution time: 0 hour(s) 0 minute(s) 6 second(s) ApexSQL Generate return code is 0
Learn more about using ApexSQL Generate CLI switches here.
If any error is encountered during the execution of the CLI code for data generation, it will be written into the output file. For example, if there is some constraint or primary key violation, the following messages will be provided:
Inserting data into table Person.Customer Inserting data failed: Explicit value must be specified for identity column in table “Person.Customer” either when IDENTITY_INSERT is set to ON or when a replication user is inserting into a NOT FOR REPLICATION identity column. Inserting data into table Person.CustomerAddress Inserting data failed: Violation of primary key constraint “PK_Customer_CustID”. Cannot insert duplicate key in object “Person.CustomerAddress”. The duplicate key value is (1).
The post How to automatically create synthetic test data for a SQL Server database appeared first on Solution center.
0 notes
amonkeysden-blog · 14 years ago
Text
Scheduled Tasks into Powershell variable
$schtasks = schtasks /query /fo csv /v | ConvertFrom-Csv
0 notes
virtualizationhowto · 1 year ago
Text
Forget Task Scheduler PowerShell Scripts Use CI/CD Instead
Forget Task Scheduler PowerShell Scripts: Use CI/CD Instead @vexpert #vmwarecommunities #devops #infrastructureascode #gitlab #cicdpipelines #gitops #virtualization #virtualizationhowto #taskscheduler #scheduledtasks #powershell #scripts #homelab
If you are a Windows admin, VI Admin, or you use Windows task scheduler to run powershell scripts in your environment, you have probably noticed a few headaches with this process. Yes, it is easy enough and it is a great way to start learning how scripts can be used in an environment. However, when it comes to the process to manage scheduled tasks configured across an environment, it can be a…
Tumblr media
View On WordPress
0 notes