Snippets Collections
//Controller

using av_motion_api.Data;
using av_motion_api.Models;
using av_motion_api.ViewModels;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

namespace av_motion_api.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class RewardController : ControllerBase
    {
        private readonly AppDbContext _appDbContext;

        public RewardController(AppDbContext appDbContext)
        {
            _appDbContext = appDbContext;
        }

        [HttpGet]
        [Route("getAllRewardTypes")]
        public async Task<IActionResult> GetAllRewardTypes()
        {
            try
            {
                var rewardTypes = await _appDbContext.Reward_Types.ToListAsync();
                return Ok(rewardTypes);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpGet]
        [Route("getRewardTypeById/{id}")]
        public async Task<IActionResult> GetRewardTypeById(int id)
        {
            try
            {
                var rewardType = await _appDbContext.Reward_Types.FindAsync(id);

                if (rewardType == null)
                {
                    return NotFound();
                }

                return Ok(rewardType);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpPost]
        [Route("createRewardType")]
        public async Task<IActionResult> CreateRewardType(RewardTypeViewModel rt)
        {
            try
            {
                var existingRewardType = await _appDbContext.Reward_Types
                    .FirstOrDefaultAsync(r => r.Reward_Type_Name == rt.Reward_Type_Name);

                if (existingRewardType != null)
                {
                    return Conflict(new { message = "Reward type already exists." });
                }


                var rewardType = new Reward_Type
                {
                    Reward_Type_Name = rt.Reward_Type_Name,
                    Reward_Criteria = rt.Reward_Criteria
                    
                };
                _appDbContext.Reward_Types.Add(rewardType);
                await _appDbContext.SaveChangesAsync();

                return CreatedAtAction(nameof(GetRewardTypeById), new { id = rewardType.Reward_Type_ID }, rewardType);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpPut]
        [Route("updateRewardType/{id}")]
        public async Task<IActionResult> UpdateRewardType(int id, [FromBody] RewardTypeViewModel rt)
        {
            try
            {
                var rewardType = await _appDbContext.Reward_Types.FindAsync(id);

                if(rewardType == null)
                {
                    return NotFound();
                }

                var existingRewardType = await _appDbContext.Reward_Types
                    .FirstOrDefaultAsync(r => r.Reward_Type_Name == rt.Reward_Type_Name && r.Reward_Type_ID != id);

                if (existingRewardType != null)
                {
                    return Conflict(new { message = "Reward type already exists." });
                }

                rewardType.Reward_Type_Name = rt.Reward_Type_Name;
                rewardType.Reward_Criteria = rt.Reward_Criteria;

                _appDbContext.Entry(rewardType).State = EntityState.Modified;
                await _appDbContext.SaveChangesAsync();

                return NoContent();
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpDelete]
        [Route("deleteRewardType/{id}")]
        public async Task<IActionResult> DeleteRewardType(int id)
        {
            try
            {
                var rewardType = await _appDbContext.Reward_Types.FindAsync(id);

                if(rewardType == null)
                {
                    return NotFound();
                }

                _appDbContext.Reward_Types.Remove(rewardType);
                await _appDbContext.SaveChangesAsync();

                return NoContent();
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }



        [HttpGet]
        [Route("getRewardById/{id}")]
        public async Task<IActionResult> GetRewardById(int id)
        {
            try
            {
                var reward = await _appDbContext.Rewards.FindAsync(id);

                if (reward == null)
                {
                    return NotFound();
                }

                return Ok(reward);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpGet]
        [Route("getAllRewards")]
        public async Task<IActionResult> GetAllRewards()
        {
            try
            {
                var rewards = await _appDbContext.Rewards
                                         .Join(_appDbContext.Reward_Types,
                                               reward => reward.Reward_Type_ID,
                                               rewardType => rewardType.Reward_Type_ID,
                                               (reward, rewardType) => new RewardViewModel
                                               {
                                                   Reward_ID = reward.Reward_ID,
                                                   Reward_Issue_Date = reward.Reward_Issue_Date,
                                                   Reward_Type_Name = rewardType.Reward_Type_Name,
                                                   IsPosted = reward.IsPosted
                                               })
                                         .ToListAsync();
                return Ok(rewards);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }

        [HttpPost]
        [Route("redeemReward")]
        public async Task<IActionResult> RedeemReward([FromBody] RewardRedeemViewModel request)
        {
            try
            {
                // Fetch the reward by ID
                var reward = await _appDbContext.Reward_Members
                                                .FirstOrDefaultAsync(r => r.Reward_ID == request.RewardId && r.Member_ID == request.MemberId);

                if (reward == null)
                {
                    return NotFound("Reward not found or not eligible for the member.");
                }

                // Check if the reward is already redeemed
                if (reward.IsRedeemed)
                {
                    return BadRequest("Reward is already redeemed.");
                }

                // Mark the reward as redeemed
                reward.IsRedeemed = true;
                _appDbContext.Entry(reward).State = EntityState.Modified;
                await _appDbContext.SaveChangesAsync();

                return Ok(new { Status = "Success", Message = "Reward redeemed successfully!" });
            }
            catch (Exception)
            {
                return BadRequest("An error occurred while redeeming the reward.");
            }
        }

        [HttpPost]
        [Route("setReward")]
        public async Task<IActionResult> SetReward(RewardSetViewModel r)
        {
            try
            {
                var reward = new Reward
                {
                    Reward_Issue_Date = r.Reward_Issue_Date,
                    Reward_Type_ID = r.Reward_Type_ID,
                    IsPosted = r.IsPosted
                };
                _appDbContext.Rewards.Add(reward);
                await _appDbContext.SaveChangesAsync();

                return CreatedAtAction(nameof(GetRewardById), new { id = reward.Reward_ID }, reward);
            }
            catch (Exception)
            {
                return BadRequest();
            }
        }


        [HttpPost]
        [Route("postReward")]
        public async Task<IActionResult> PostReward([FromBody] RewardPostViewModel request)
        {
            try
            {
                // Fetch the reward by ID
                var reward = await _appDbContext.Rewards
                                                .FirstOrDefaultAsync(r => r.Reward_ID == request.RewardId);

                if (reward == null)
                {
                    return NotFound("Reward not found.");
                }

                // Check if the reward is already posted
                if (reward.IsPosted)
                {
                    return BadRequest("Reward is already posted.");
                }

                // Mark the reward as posted
                reward.IsPosted = true;
                _appDbContext.Entry(reward).State = EntityState.Modified;
                await _appDbContext.SaveChangesAsync();

                // Fetch members who qualify for this reward based on the criteria
                var rewardType = await _appDbContext.Reward_Types.FindAsync(reward.Reward_Type_ID);
                var qualifyingMembers = await GetQualifyingMembers(rewardType.Reward_Criteria);

                // Add qualifying members to the Reward_Member table
                foreach (var member in qualifyingMembers)
                {
                    var rewardMember = new Reward_Member
                    {
                        Member_ID = member.Member_ID,
                        Reward_ID = reward.Reward_ID,
                        IsRedeemed = false
                    };
                    _appDbContext.Reward_Members.Add(rewardMember);
                }
                await _appDbContext.SaveChangesAsync();

                return Ok(new { Status = "Success", Message = "Reward posted successfully!" });
            }
            catch (Exception)
            {
                return BadRequest("An error occurred while posting the reward.");
            }
        }

        //Predined Reward Types Methods
        private async Task<List<Member>> GetQualifyingMembers(string criteria)
        {
            var qualifyingMembers = new List<Member>();

            if (criteria == "Completed 10 Bookings in a Month")
            {
                qualifyingMembers = await GetMembersWithBookingsInMonth(10);
            }
            else if (criteria == "Member for Over a Year")
            {
                qualifyingMembers = await GetLoyalMembers();
            }
            else if (criteria == "Made 20 Bookings in Last 3 Months")
            {
                qualifyingMembers = await GetFrequentBookers(20, 3);
            }
            //else if (criteria == "Perfect Attendance for a Month")
            //{
            //    qualifyingMembers = await GetPerfectAttendanceMembers();
            //}
            //else if (criteria == "Consistent Attendance for a Quarter")
            //{
            //    qualifyingMembers = await GetConsistentAttendanceMembers();
            //}

            return qualifyingMembers;
        }

        private async Task<List<Member>> GetMembersWithBookingsInMonth(int bookingCount)
        {
            var oneMonthAgo = DateTime.Now.AddMonths(-1);
            var qualifyingMembers = await _appDbContext.Members
                .Where(m => _appDbContext.Bookings
                    .Where(b => b.Member_ID == m.Member_ID)
                    .Join(_appDbContext.Booking_Time_Slots,
                          b => b.Booking_ID,
                          bts => bts.Booking_ID,
                          (b, bts) => bts.Time_Slot_ID)
                    .Join(_appDbContext.Time_Slots,
                          btsId => btsId,
                          ts => ts.Time_Slot_ID,
                          (btsId, ts) => ts)
                    .Count(ts => ts.Slot_Date >= oneMonthAgo) >= bookingCount)
                .ToListAsync();

            return qualifyingMembers;
        }

        private async Task<List<Member>> GetLoyalMembers()
        {
            var oneYearAgo = DateTime.Now.AddYears(-1);
            var qualifyingMembers = await _appDbContext.Members
                .Join(_appDbContext.Contracts,
                      m => m.Contract_ID,
                      c => c.Contract_ID,
                      (m, c) => new { Member = m, Contract = c })
                .Where(mc => mc.Contract.Subscription_Date <= oneYearAgo)
                .Select(mc => mc.Member)
                .ToListAsync();

            return qualifyingMembers;
        }


        private async Task<List<Member>> GetFrequentBookers(int bookingCount, int months)
        {
            var dateLimit = DateTime.Now.AddMonths(-months);
            var qualifyingMembers = await _appDbContext.Members
                .Where(m => _appDbContext.Bookings
                    .Where(b => b.Member_ID == m.Member_ID)
                    .Join(_appDbContext.Booking_Time_Slots,
                          b => b.Booking_ID,
                          bts => bts.Booking_ID,
                          (b, bts) => bts.Time_Slot_ID)
                    .Join(_appDbContext.Time_Slots,
                          btsId => btsId,
                          ts => ts.Time_Slot_ID,
                          (btsId, ts) => ts)
                    .Count(ts => ts.Slot_Date >= dateLimit) >= bookingCount)
                .ToListAsync();

            return qualifyingMembers;
        }

        //private async Task<List<Member>> GetPerfectAttendanceMembers()
        //{
        //    var startDate = DateTime.Now.AddMonths(-1);
        //    var qualifyingMembers = await _appDbContext.Members
        //        .Where(m => _appDbContext.Attendance_Lists
        //            .Count(a => a.Member_ID == m.Member_ID && a.Slot_Date >= startDate && a.Members_Present > 0) == 30)
        //        .ToListAsync();

        //    return qualifyingMembers;
        //}

        //private async Task<List<Member>> GetConsistentAttendanceMembers()
        //{
        //    var startDate = DateTime.Now.AddMonths(-3);
        //    var qualifyingMembers = await _appDbContext.Members
        //        .Where(m => _appDbContext.Attendance_Lists
        //            .Count(a => a.Member_ID == m.Member_ID && a.Slot_Date >= startDate && a.Members_Present > 0) >= 12)
        //        .ToListAsync();

        //    return qualifyingMembers;
        //}
    }
}
    //Predined Reward Types Methods
    private async Task<List<Member>> GetQualifyingMembers(string criteria)
    {
        var qualifyingMembers = new List<Member>();

        if (criteria == "Completed 10 Bookings in a Month")
        {
            qualifyingMembers = await GetMembersWithBookingsInMonth(10);
        }
        else if (criteria == "Member for Over a Year")
        {
            qualifyingMembers = await GetLoyalMembers();
        }
        else if (criteria == "Made 20 Bookings in Last 3 Months")
        {
            qualifyingMembers = await GetFrequentBookers(20, 3);
        }
        //else if (criteria == "Perfect Attendance for a Month")
        //{
        //    qualifyingMembers = await GetPerfectAttendanceMembers();
        //}
        //else if (criteria == "Consistent Attendance for a Quarter")
        //{
        //    qualifyingMembers = await GetConsistentAttendanceMembers();
        //}

        return qualifyingMembers;
    }

    private async Task<List<Member>> GetMembersWithBookingsInMonth(int bookingCount)
    {
        var oneMonthAgo = DateTime.Now.AddMonths(-1);
        var qualifyingMembers = await _appDbContext.Members
            .Where(m => _appDbContext.Bookings
                .Where(b => b.Member_ID == m.Member_ID)
                .Join(_appDbContext.Booking_Time_Slots,
                      b => b.Booking_ID,
                      bts => bts.Booking_ID,
                      (b, bts) => bts.Time_Slot_ID)
                .Join(_appDbContext.Time_Slots,
                      btsId => btsId,
                      ts => ts.Time_Slot_ID,
                      (btsId, ts) => ts)
                .Count(ts => ts.Slot_Date >= oneMonthAgo) >= bookingCount)
            .ToListAsync();

        return qualifyingMembers;
    }

    private async Task<List<Member>> GetLoyalMembers()
    {
        var oneYearAgo = DateTime.Now.AddYears(-1);
        var qualifyingMembers = await _appDbContext.Members
            .Join(_appDbContext.Contracts,
                  m => m.Contract_ID,
                  c => c.Contract_ID,
                  (m, c) => new { Member = m, Contract = c })
            .Where(mc => mc.Contract.Subscription_Date <= oneYearAgo)
            .Select(mc => mc.Member)
            .ToListAsync();

        return qualifyingMembers;
    }


    private async Task<List<Member>> GetFrequentBookers(int bookingCount, int months)
    {
        var dateLimit = DateTime.Now.AddMonths(-months);
        var qualifyingMembers = await _appDbContext.Members
            .Where(m => _appDbContext.Bookings
                .Where(b => b.Member_ID == m.Member_ID)
                .Join(_appDbContext.Booking_Time_Slots,
                      b => b.Booking_ID,
                      bts => bts.Booking_ID,
                      (b, bts) => bts.Time_Slot_ID)
                .Join(_appDbContext.Time_Slots,
                      btsId => btsId,
                      ts => ts.Time_Slot_ID,
                      (btsId, ts) => ts)
                .Count(ts => ts.Slot_Date >= dateLimit) >= bookingCount)
            .ToListAsync();

        return qualifyingMembers;
    }

    //private async Task<List<Member>> GetPerfectAttendanceMembers()
    //{
    //    var startDate = DateTime.Now.AddMonths(-1);
    //    var qualifyingMembers = await _appDbContext.Members
    //        .Where(m => _appDbContext.Attendance_Lists
    //            .Count(a => a.Member_ID == m.Member_ID && a.Slot_Date >= startDate && a.Members_Present > 0) == 30)
    //        .ToListAsync();

    //    return qualifyingMembers;
    //}

    //private async Task<List<Member>> GetConsistentAttendanceMembers()
    //{
    //    var startDate = DateTime.Now.AddMonths(-3);
    //    var qualifyingMembers = await _appDbContext.Members
    //        .Where(m => _appDbContext.Attendance_Lists
    //            .Count(a => a.Member_ID == m.Member_ID && a.Slot_Date >= startDate && a.Members_Present > 0) >= 12)
    //        .ToListAsync();

    //    return qualifyingMembers;
    //}
}
EMCommonWebAPI  webAPI = EMCommonWebAPI::construct();       
// Prepare the request   
EMWebRequest    webRequest = EMWebRequest::newUrl('https://api.restful-api.dev/objects');
   
// Set the method to use
webRequest.parmMethod('Post');
System.Text.UTF8Encoding encoder;
encoder = new System.Text.UTF8Encoding();

// Initialize the contract to prepare the body
NSHEContract contract = new NSHEContract();
contract.parmName('NShe MacBook Pro 16');
        
NSHEContractData contractData = new  NSHEContractData();
contractData.parmCPUModel('Fast model x');
contractData.parmhardDiskSize('225 GB');
contractData.parmPrice(2000);
contractData.parmYear(2023);
contract.parmData(contractData);

//Convert the data contract to Binary         
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Byte[] encodedBytes = encoder.GetBytes(FormJsonSerializer::serializeClass(contract));
stream.Write(encodedBytes, 0, encodedBytes.get_Length());
Binary content = binary::constructFromMemoryStream(stream);
stream.Close();

//Set the body of the request
webRequest.parmContent(content);
webRequest.parmContentType('application/json');

// Get the response by calling the API
EMWebResponse   webresponse = webAPI.getResponse(webRequest);
        
if (webresponse && webresponse.RequestSucceeded())
{
    info ('Succedded');
}
# Analyzing Clicks A Python Function for Extracting Weekly Stats

users_data = [
    {'day': 0, 'clicks': 100}, {'day': 1, 'clicks': 10},
    {'day': 2, 'clicks': 150}, {'day': 3, 'clicks': 1000},
    {'day': 4, 'clicks': 100}, {'day': 5, 'clicks': 190},
    {'day': 6, 'clicks': 150}, {'day': 7, 'clicks': 1000}
]

def get_stats(day):
    # -1 to start from day 0 because day in date is 1
    return users_data[day - 1: day + 7]

print(get_stats(1))
"AccountNumber": "PNJ01",
   "D_VALN_AS_OF": "2022-06-30 00:00:00.0",
     "T_DTL_DESC": "EWTP ARABIA TECHONLOGY INNOVATION FUND ILP",
       "N-INV-SUB-CATG": "Partnerships",
         "Asset Super Category Name": "Venture Capital and Partnerships",
           "A_ADJ_BAS_BSE": "47947573",
             "A_UNRL_MKT_GNLS": "50275681",
               "ProprietarySymbol": "993FD3998",
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Define the data to be inserted as a list of tuples
data = [
    ('John Doe', 'johndoe@example.com'),
    ('Jane Smith', 'janesmith@example.com'),
    ('Mike Johnson', 'mikejohnson@example.com')
]

# Use executemany() to insert the data into the "users" table
cursor.executemany("INSERT INTO users (name, email) VALUES (?, ?)", data)

# Commit the changes
con.commit()
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Update user name based on ID
user_id = 2
new_name = "John Doe"

cursor.execute("UPDATE users SET name = ? WHERE id = ?", (new_name, user_id))

# Commit the changes
con.commit()
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Fetch all data from the "users" table
cursor.execute("SELECT * FROM users")
data = cursor.fetchall()

# Print the retrieved data
for row in data:
    print(row)
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Delete user based on ID
user_id = 123

cursor.execute("DELETE FROM users WHERE id = ?", (user_id,))

# Commit the changes
con.commit()
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Fetch data based on the ID filter
cursor.execute("SELECT * FROM users WHERE id = ?", (123,))
data = cursor.fetchall()

# Print the retrieved data
for row in data:
    print(row)

New-Item -Path WSMan:\localhost\Plugin\TestPlugin\InitializationParameters `
         -ParamName testparametername `
         -ParamValue testparametervalue
import sqlite3

# Connect to the database
con = sqlite3.connect('database.db')

# Create a cursor object
cursor = con.cursor()

# Create a cursor object
cursor = con.cursor()

# Insert a new user
cursor.execute("INSERT INTO users (name, email) VALUES (?, ?)", ("John Doe", "johndoe@example.com"))

# Commit the changes
con.commit()

MyModel::withTrashed()->updateOrCreate([
   'foo' => $foo,
	// ...
], [
   'deleted_at' => null,
	// ...
]);
$this->sizesInterface->withTrashed()->updateOrCreate(
            ['size' => $r->input('size')],
            $r->all())->restore();
$cred = Get-Credential
New-Item -Path WSMan:\localhost\ClientCertificate `
         -Issuer 1b3fd224d66c6413fe20d21e38b304226d192dfe `
         -URI wmicimv2/* `
         -Credential $cred;
$path = "WSMan:\localhost\Plugin\TestPlugin\Resources\Resource_5967683"
New-Item -Path $path\Security `
         -Sddl "O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)"
New-Item -Path WSMan:\localhost\Plugin\TestPlugin\Resources `
         -ResourceUri http://schemas.dmtf.org/wbem/wscim/3/cim-schema `
         -Capability "Enumerate"

New-Item -Path WSMan:\localhost\Plugin `
         -Plugin TestPlugin `
         -FileName %systemroot%\system32\WsmWmiPl.dll `
         -Resource http://schemas.dmtf.org/wbem/wscim/2/cim-schema `
         -SDKVersion 1 `
         -Capability "Get","Put","Invoke","Enumerate" `
         -XMLRenderingType text
New-Item -Path WSMan:\localhost\Listener -Address * -Transport HTTP -force
// Abstract class Animal

abstract class Animal {

    // Properties

    String name;

    int age;

    // Constructor

    public Animal(String name, int age) {

        this.name = name;

        this.age = age;

    }

    // Abstract method

    public abstract void sound();

    // Method

    public void sleep() {

        System.out.println(name + " is sleeping.");

    }

    // Method to display details of the animal

    public void displayDetails() {

        System.out.println("Name: " + name + ", Age: " + age);

    }

}

// Child class Dog inheriting from Animal

class Dog extends Animal {

    // Additional property

    String breed;

    // Constructor

    public Dog(String name, int age, String breed) {

        // Call to parent class constructor

        super(name, age);

        this.breed = breed;

    }

    // Method overriding

    @Override

    public void sleep() {

        System.out.println(name + " the dog is sleeping.");

    }

    @Override

    public void sound() {

        System.out.println(name + " says Woof!");

    }

    // Additional method specific to Dog

    public void bark() {

        System.out.println(name + " is barking.");

    }

    @Override

    public void displayDetails() {

        super.displayDetails();

        System.out.println("Breed: " + breed);

    }

}

// Child class Cat inheriting from Animal

class Cat extends Animal {

    // Additional property

    String color;

    // Constructor

    public Cat(String name, int age, String color) {

        super(name, age);

        this.color = color;

    }

    // Method overriding

    @Override

    public void sleep() {

        System.out.println(name + " the cat is sleeping.");

    }

    @Override

    public void sound() {

        System.out.println(name + " says Meow!");

    }

    // Additional method specific to Cat

    public void meow() {

        System.out.println(name + " is meowing.");

    }

    @Override

    public void displayDetails() {

        super.displayDetails();

        System.out.println("Color: " + color);

    }

}

// Main class

public class Main {

    public static void main(String[] args) {

        // Create instances of Animal

        Animal[] animals = new Animal[3];

        animals[0] = new Dog("Buddy", 3, "Labrador");

        animals[1] = new Cat("Whiskers", 2, "White");

        animals[2] = new Dog("Rex", 4, "German Shepherd");

        // Display details and demonstrate polymorphism

        for (Animal animal : animals) {

            animal.displayDetails();

            animal.sleep();

            animal.sound();

            System.out.println();

        }

    }

}
function Test-AllConfigFiles
{
    Get-PSSessionConfiguration | ForEach-Object {
        if ($_.ConfigFilePath) {
            $_.ConfigFilePath
            Test-PSSessionConfigurationFile -Verbose -Path $_.ConfigFilePath
        }
    }
}
Test-AllConfigFiles

C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Empty_6fd77bf6-e084-4372-bd8a-af3e207354d3.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Full_1e9cb265-dae0-4bd3-89a9-8338a47698a1.pssc
VERBOSE: The member 'AliasDefinitions' must contain the required key 'Description'. Add the require key
to the fileC:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\Full_1e9cb265-dae0-4bd3-89a9-8338a47698a1.pssc.
False
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\NoLanguage_0c115179-ff2a-4f66-a5eb-e56e5692ba22.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\RestrictedLang_b6bd9474-0a6c-4e06-8722-c2c95bb10d3e.pssc
True
C:\WINDOWS\System32\WindowsPowerShell\v1.0\SessionConfig\RRS_3fb29420-2c87-46e5-a402-e21436331efc.pssc
True
Test-PSSessionConfigurationFile -Path (Get-PSSessionConfiguration -Name Restricted).ConfigFilePath
Invoke-Command
Receive-Job
Remove-Job
Resume-Job
Start-Job
Stop-Job
Suspend-Job
Wait-Job
about_Jobs
about_Job_Details
about_Remote_Jobs
about_Scheduled_Jobs
PS> Get-Job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost            .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02   .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> Get-Job -IncludeChildJob

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost           .\Get-Archive.ps1
3      Job3                            Completed     True            localhost           .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02  .\Get-Archive.ps1
5      Job5                            Failed        False           Server01            .\Get-Archive.ps1
6      Job6                            Completed     True            Server02            .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> Get-Job -Name Job4 -ChildJobState Failed

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
2      Job2            BackgroundJob   Completed     True            localhost           .\Get-Archive.ps1
4      Job4            RemoteJob       Failed        True            Server01, Server02  .\Get-Archive.ps1
5      Job5                            Failed        False           Server01            .\Get-Archive.ps1
7      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
8      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
9      UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help
10     UpdateHelpJob   PSScheduledJob  Completed     True            localhost            Update-Help

PS> (Get-Job -Name Job5).JobStateInfo.Reason

Connecting to remote server Server01 failed with the following error message:
Access is denied.
PS> Workflow WFProcess {Get-Process}
PS> WFProcess -AsJob -JobName WFProcessJob -PSPrivateMetadata @{MyCustomId = 92107}
PS> Get-Job -Filter @{MyCustomId = 92107}
Id     Name            State         HasMoreData     Location             Command
--     ----            -----         -----------     --------             -------
1      WFProcessJob    Completed     True            localhost            WFProcess
PS> Start-Job -ScriptBlock {Get-Process}
Id     Name       PSJobTypeName   State       HasMoreData     Location             Command
--     ----       -------------   -----       -----------     --------             -------
1      Job1       BackgroundJob   Failed      False           localhost            Get-Process

PS> (Get-Job).JobStateInfo | Format-List -Property *
State  : Failed
Reason :

PS> Get-Job | Format-List -Property *
HasMoreData   : False
StatusMessage :
Location      : localhost
Command       : get-process
JobStateInfo  : Failed
Finished      : System.Threading.ManualReset
EventInstanceId    : fb792295-1318-4f5d-8ac8-8a89c5261507
Id            : 1
Name          : Job1
ChildJobs     : {Job2}
Output        : {}
Error         : {}
Progress      : {}
Verbose       : {}
Debug         : {}
Warning       : {}
StateChanged  :

PS> (Get-Job -Name job2).JobStateInfo.Reason
Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the
following error message: Access is denied.
Start-Job -ScriptBlock {Get-EventLog -LogName System}
Invoke-Command -ComputerName S1 -ScriptBlock {Get-EventLog -LogName System} -AsJob
Invoke-Command -ComputerName S2 -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Get-Job

Id     Name       PSJobTypeName   State         HasMoreData     Location        Command
--     ----       -------------   -----         -----------     --------        -------
1      Job1       BackgroundJob   Running       True            localhost       Get-EventLog System
2      Job2       RemoteJob       Running       True            S1              Get-EventLog System

$Session = New-PSSession -ComputerName S2
Invoke-Command -Session $Session -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $Session -ScriptBlock {Get-Job}

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command                   PSComputerName
--     ----            -------------   -----         -----------     --------             -------                   --------------
1      Job1            BackgroundJob   Running       True            localhost            Get-EventLog -LogName Sy… S2
Start-Job -ScriptBlock {Get-Process} -Name MyJob
$j = Get-Job -Name MyJob
$j

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
6      MyJob           BackgroundJob   Completed     True            localhost            Get-Process

Receive-Job -Job $j

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    124       4    13572      12080    59            1140 audiodg
    783      16    11428      13636   100             548 CcmExec
     96       4     4252       3764    59            3856 ccmsetup
...
Get-Job -Command "*Get-Process*"

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
3      Job3            BackgroundJob   Running       True            localhost            Get-Process
$j = Get-Job -Name Job1
$ID = $j.InstanceID
$ID

Guid
----
03c3232e-1d23-453b-a6f4-ed73c9e29d55

Stop-Job -InstanceId $ID
Get-Job

Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
--     ----            -------------   -----         -----------     --------             -------
1      Job1            BackgroundJob   Completed     True            localhost             $env:COMPUTERNAME
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [-Command <String[]>]
   [<CommonParameters>]
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [-Command <String[]>]
   [<CommonParameters>]
Get-Job
   [-IncludeChildJob]
   [-ChildJobState <JobState>]
   [-HasMoreData <Boolean>]
   [-Before <DateTime>]
   [-After <DateTime>]
   [-Newest <Int32>]
   [[-Id] <Int32[]>]
   [<CommonParameters>]
Get-Command
   [[-Name] <String[]>]
   [-Module <String[]>]
   [-FullyQualifiedModule <ModuleSpecification[]>]
   [-CommandType <CommandTypes>]
   [-TotalCount <Int32>]
   [-Syntax]
   [-ShowCommandInfo]
   [[-ArgumentList] <Object[]>]
   [-All]
   [-ListImported]
   [-ParameterName <String[]>]
   [-ParameterType <PSTypeName[]>]
   [<CommonParameters>]
Get-Command
   [-Verb <String[]>]
   [-Noun <String[]>]
   [-Module <String[]>]
   [-FullyQualifiedModule <ModuleSpecification[]>]
   [-TotalCount <Int32>]
   [-Syntax]
   [-ShowCommandInfo]
   [[-ArgumentList] <Object[]>]
   [-All]
   [-ListImported]
   [-ParameterName <String[]>]
   [-ParameterType <PSTypeName[]>]
   [<CommonParameters>]
Get-Process -Name Explorer, Winlogon, Services
$cmd = Get-Command Get-Random
$cmd.ParameterSets |
    Select-Object Name, IsDefault, @{n='Parameters';e={$_.ToString()}} |
    Format-Table -Wrap
NAME
    Get-Command

SYNOPSIS
    Gets all commands.

SYNTAX

    Get-Command [[-Name] <System.String[]>] [[-ArgumentList] <System.Object[]>]
    [-All] [-CommandType {Alias | Function | Filter | Cmdlet | ExternalScript |
    Application | Script | Workflow | Configuration | All}]
    [-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecification[]>]
    [-ListImported] [-Module <System.String[]>] [-ParameterName <System.String[]>]
    [-ParameterType <System.Management.Automation.PSTypeName[]>]
    [-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>]
    [-UseAbbreviationExpansion] [-UseFuzzyMatching] [<CommonParameters>]

    Get-Command [[-ArgumentList] <System.Object[]>] [-All]
    [-FullyQualifiedModule <Microsoft.PowerShell.Commands.ModuleSpecification[]>]
    [-ListImported] [-Module <System.String[]>] [-Noun <System.String[]>]
    [-ParameterName <System.String[]>]
    [-ParameterType <System.Management.Automation.PSTypeName[]>]
    [-ShowCommandInfo] [-Syntax] [-TotalCount <System.Int32>]
    [-Verb <System.String[]>] [<CommonParameters>]
...
star

Tue Jul 09 2024 11:16:14 GMT+0000 (Coordinated Universal Time)

@iamkatmakhafola

star

Tue Jul 09 2024 10:40:26 GMT+0000 (Coordinated Universal Time) https://maticz.com/educational-app-development

@carolinemax ##educational_app_development ##maticz ##usa ##educational_app_development_company

star

Tue Jul 09 2024 10:10:17 GMT+0000 (Coordinated Universal Time)

@iamkatmakhafola

star

Tue Jul 09 2024 09:08:12 GMT+0000 (Coordinated Universal Time)

@Mohamed2210

star

Tue Jul 09 2024 08:43:28 GMT+0000 (Coordinated Universal Time)

@Mohamed2210

star

Tue Jul 09 2024 07:49:34 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 07:31:43 GMT+0000 (Coordinated Universal Time) https://laracasts.com/discuss/channels/eloquent/update-or-create-and-restore-soft-deleted-model

@xsirlalo

star

Tue Jul 09 2024 07:31:28 GMT+0000 (Coordinated Universal Time) https://es.stackoverflow.com/questions/105332/restaurar-soft-delete-laravel

@xsirlalo

star

Tue Jul 09 2024 06:44:59 GMT+0000 (Coordinated Universal Time) https://mdl-e0520a.design.webflow.com/

@Flowr1x

star

Tue Jul 09 2024 06:30:15 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 06:30:00 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 06:29:48 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 06:29:38 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 06:29:26 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.wsman.management/about/about_wsman_provider?view

@Dewaldt

star

Tue Jul 09 2024 02:59:38 GMT+0000 (Coordinated Universal Time)

@chinnu

star

Tue Jul 09 2024 01:39:45 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:39:32 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:39:23 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:39:05 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/test-pssessionconfigurationfile?view

@Dewaldt

star

Tue Jul 09 2024 01:38:25 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:36:57 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:35:39 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:35:29 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:50 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:38 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:34:26 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:35 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:25 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:33:15 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:42 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:17 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:32:06 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-job?view

@Dewaldt

star

Tue Jul 09 2024 01:31:43 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-command?view

@Dewaldt

star

Tue Jul 09 2024 01:31:28 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/get-command?view

@Dewaldt

star

Tue Jul 09 2024 01:30:37 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:30:24 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:30:03 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:57 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:36 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:29:27 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:28:35 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

star

Tue Jul 09 2024 01:28:07 GMT+0000 (Coordinated Universal Time) https://learn.microsoft.com/en-za/powershell/module/microsoft.powershell.core/about/about_command_syntax?view

@Dewaldt

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension