-
Notifications
You must be signed in to change notification settings - Fork 1
/
to-do.txt
47 lines (41 loc) · 2.86 KB
/
to-do.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
1. Install pster and take notes;
(new-object Net.WebClient).DownloadString("http://bit.ly/GetPsGet") | iex
import-module PsGet
install-module Pester
2. Play with Pester and follow the first test case
New-Fixture -path folderName -name functionName
Note: The command above creates a PowerShell function file and its test file in folderName. What I decided for now is to create a folder called Dev, because I'd prefer a separation of actual function files and their tests in their final release.
Then while in folderName, run Invoke-Pester to run the tests. So far it works well.
3. Install AD PowerShell modules. At this stage please make sure you are running PowerShell under Administrator. You need to specifically pick "Run as Administrator", even if the account you logged in as has local admin privileges.Ignore the warning about "Windows automatic update" if you have Windows automatic update turned off.
Import-Module ServerManager
Get-WindowsFeature
Add-WindowsFeature RSAT-AD-PowerShell
Add-WindowsFeature RSAT-AD-AdminCenter
To look at what CmdLet and functions are provided by a module, use Get-Command -Module <ModuleName>
4. Use Pester, write a function to get group members:
a. logins only (no nested group names)
b. If a group has nested groups, get their individual members as well
5. Write a delete nibbler
6. Function to project backup and restore time based on progress and history:
SELECT command,
s.text,
start_time,
percent_complete,
CAST(((DATEDIFF(s,start_time,GetDate()))/3600) as varchar) + ' hour(s), '
+ CAST((DATEDIFF(s,start_time,GetDate())%3600)/60 as varchar) + 'min, '
+ CAST((DATEDIFF(s,start_time,GetDate())%60) as varchar) + ' sec' as running_time,
CAST((estimated_completion_time/3600000) as varchar) + ' hour(s), '
+ CAST((estimated_completion_time %3600000)/60000 as varchar) + 'min, '
+ CAST((estimated_completion_time %60000)/1000 as varchar) + ' sec' as est_time_to_go,
dateadd(second,estimated_completion_time/1000, getdate()) as est_completion_time
FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s
WHERE r.command in ('RESTORE DATABASE', 'BACKUP DATABASE', 'RESTORE LOG', 'BACKUP LOG')
For scanning SQL Server error log and SQL Server Agent log, I will be using Get-WinEvent, since it is faster than Get-EventLog. Get-WinEvent only works for servers running Windows 2008 and above. *On second thought, let me work on something else first and let this cook in my head a bit longer*
select name, * from sys.server_principals
where is_disabled = 0 and type = 'S' and IS_SRVROLEMEMBER('sysadmin', name) = 1
select name, * from sys.server_principals
where is_disabled = 0 and type = 'G' and IS_SRVROLEMEMBER('sysadmin', name) = 1
select name, * from sys.server_principals
where is_disabled = 0 and type = 'u' and IS_SRVROLEMEMBER('sysadmin', name) = 1
7. Now I am trying to get Tengine working:
sudo apt-get install libpcre3-dev for PCRE library