블로그 이미지
SQL Server VS. 석이 minsouk@hotmail.com MSSQL 쿼리성능 관련해 궁금한 사항이 있다면 언제나 누구나 TeamViewer + Line (네이버 japan 메신저) 에 minsouk1 추가 후 연락주세요~ 010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (441)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total196,518
Today21
Yesterday61

달력

« » 2017.06
        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  

공지사항

'2017/06/05'에 해당되는 글 1건

  1. 2017.06.05 powershell

powershell

분류없음 / 2017.06.05 11:17

remote command 활성화

https://technet.microsoft.com/en-us/library/ff700227.aspx

 

 

 

get-service winrm

Start-Service winrm

get-service winrm

winrm s winrm/config/client '@{TrustedHosts="WIN-6S4NEPKTVUI"}'

winrm quickconfig

 

파일 /  새 원격 PowerShell 탭

인증 ...

 

 

 

PowerShell 책

http://www.reedbushey.com/86Windows%20Powershell%20Cookbook%203rd%20Edition.pdf

 

 

C# 으로 powershell 불러쓰기

https://blogs.msdn.microsoft.com/kebab/2014/04/28/executing-powershell-scripts-from-c/

 

 

 

sql parameter

http://sql-articles.com/articles/general/enable-disable-trace-flags-in-sql-server/

 

 

 

기본 쿼리

https://msdn.microsoft.com/ko-kr/powershell/scripting/getting-started/cookbooks/working-with-registry-entries

 

 

sql parameter 쿼리하기

[mon]: PS C:\Users\db\Documents> Get-ItemProperty -Path Registry::"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\Parameters"

 

파일 읽어서 반환하기

 

등등

 

 using (PowerShell PowerShellInstance = PowerShell.Create())
                {

                    string cmd = @"Get-Item -Path Registry::\'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server'";
                    PowerShellInstance.AddScript(cmd);
                    Console.WriteLine(cmd);

                    Collection<PSObject> PSOutput = PowerShellInstance.Invoke();
                    foreach (PSObject outputItem in PSOutput)
                    {
                        // if null object was dumped to the pipeline during the script then a null
                        // object may be present here. check for null to prevent potential NRE.
                        if (outputItem != null)
                        {
                            if (PowerShellInstance.Streams.Error.Count > 0)
                            {
                                Console.WriteLine("Error");
                            }
                            else
                            {
                                Console.WriteLine(outputItem.BaseObject.GetType().FullName);
                                Console.WriteLine(outputItem.BaseObject.ToString() + "\n");

                                if (outputItem.BaseObject is RegistryKey)
                                {
                                    RegistryKey rk = outputItem.BaseObject as RegistryKey;
                                    string[] valueNames = rk.GetValueNames();
                                    foreach (string s in valueNames)
                                    {
                                        RegistryValueKind rvk = rk.GetValueKind(s);
                                        switch (rvk)
                                        {
                                            case RegistryValueKind.MultiString:
                                                string[] values = (string[])rk.GetValue(s);
                                                Console.Write("\r\n {0} ({1}) =", s, rvk);
                                                for (int i = 0; i < values.Length; i++)
                                                {
                                                    if (i != 0) Console.Write(",");
                                                    Console.Write(" \"{0}\"", values[i]);
                                                }
                                                Console.WriteLine();
                                                break;

                                            case RegistryValueKind.Binary:
                                                byte[] bytes = (byte[])rk.GetValue(s);
                                                Console.Write("\r\n {0} ({1}) =", s, rvk);
                                                for (int i = 0; i < bytes.Length; i++)
                                                {
                                                    // Display each byte as two hexadecimal digits.
                                                    Console.Write(" {0:X2}", bytes[i]);
                                                }
                                                Console.WriteLine();
                                                break;

                                            default:
                                                Console.WriteLine("\r\n {0} ({1}) = {2}", s, rvk, rk.GetValue(s));
                                                break;
                                        }
                                    }
                                }

 

                            }
                        }
                       

                    }
                }
 

저작자 표시 비영리 변경 금지
신고
Posted by 보미아빠

최근에 달린 댓글

최근에 받은 트랙백

글 보관함