This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Param ( | |
| [string]$IP,[string]$Name,[string]$Password | |
| ) | |
| $stockPass = ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force # Default password | |
| $securePass = ConvertTo-SecureString $Password -AsPlainText -Force # new target password | |
| $stockCreds = New-Object System.Management.Automation.PSCredential("$IP\Administrator", $stockPass) | |
| $newCreds = New-Object System.Management.Automation.PSCredential("$IP\Administrator", $securePass) | |
| Get-Service -Name WinRM | Start-Service -Verbose # Ensure WS-Man is started |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| internal class Delay | |
| { | |
| public TimeSpan DelayTime { get; set; } | |
| public int Multiplier { get; set; } | |
| public TimeSpan ResetTime { get; set; } | |
| public int TerminationThreshold { get; set; } | |
| } | |
| internal class DelayManager | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void CreateIndexFromType(Type t) | |
| { | |
| var indexName = t.Name.ToLower(); | |
| if (SearchClient.Indexes.Exists(indexName)) | |
| { | |
| Trace.WriteLine("Found existing index, deleting..."); | |
| SearchClient.Indexes.Delete(indexName); | |
| } | |
| try |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SomeEntity : TableEntity | |
| { | |
| [IndexMetadata("Id", IsKey = true, IsRetrievable = true, IsSearchable = true, IsSortable = true)] | |
| public string Id | |
| { | |
| get { return RowKey; } | |
| set { RowKey = value; } | |
| } | |
| [IndexMetadata("Title", IsKey = false, IsRetrievable = true, IsSearchable = true, IsSortable = true)] | |
| public string Title { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async static void AddDocuments<T>(IList<T> things) where T : class, new() | |
| { | |
| var indexClient = new SearchIndexClient(ConfigurationManager.AppSettings["SearchServiceName"], things.First().GetType().Name.ToLower(), new SearchCredentials(ConfigurationManager.AppSettings["SearchServiceApiKey"])); | |
| try | |
| { | |
| Trace.WriteLine($"Adding {things.Count()} documents to the index..."); | |
| var thingsToIndex = things.Where(x => x.GetType().GetProperties().Any(prop => prop.GetCustomAttribute<IndexMetadataAttribute>() != null)); | |
| var newThings = thingsToIndex.Select(x => | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "oauth2Permissions": [ | |
| { | |
| "adminConsentDescription": "Allow the application access to the service", | |
| "adminConsentDisplayName": "Have full access to the service", | |
| "id": "b69ee3c9-c40d-4f2a-ac80-961cd1534e40", | |
| "isEnabled": true, | |
| "origin": "Application", | |
| "type": "User", | |
| "userConsentDescription": "Allow the application full access to the service on your behalf", | |
| "userConsentDisplayName": "Have full access to the service", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = new Auth.AuthServiceClient(); | |
| a.Endpoint.AddAuthorizationEndpointBehavior(); | |
| var me = a.WhoAmI(); | |
| Console.WriteLine(me); | |
| Console.ReadLine(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class EndpointExtension | |
| { | |
| public static void AddAuthorizationEndpointBehavior(this ServiceEndpoint endpoint) | |
| { | |
| endpoint.EndpointBehaviors.Add(new AuthorizationHeaderEndpointBehavior()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class AzureAdToken | |
| { | |
| public static string Get() | |
| { | |
| const string clientSecret = "CLIENT_SECRET"; | |
| const string clientId = "CLIENT_ID"; | |
| var ctx = new AuthenticationContext("https://login.windows.net/TENANT_NAME_OR_ID"); | |
| var token = ctx.AcquireToken("TARGET_RESOURCE", new ClientCredential(clientId, clientSecret)); | |
| return token.AccessToken; | |
| } |