블로그 이미지
010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (500)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

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

공지사항

최근에 올라온 글

powershell

카테고리 없음 / 2017. 6. 5. 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 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함